@tmbr/bundler 1.9.0 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -0
- package/cli.js +19 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# tmbr-bundler
|
|
2
2
|
|
|
3
|
+
A configurable JavaScript and CSS bundler built on [esbuild](https://esbuild.github.io) and [browser-sync](https://browsersync.io). Specifically developed for WordPress development where CI/CD is not available, allowing for concurrent development and production bundles.
|
|
4
|
+
|
|
5
|
+
**Why [esbuild](https://esbuild.github.io)?**
|
|
6
|
+
|
|
7
|
+
Compared to the mess of webpack loaders and dependencies, esbuild is faster, has better documentation and zero dependencies by default. It was created by Evan Wallace, who built this amazing [WebGL demo](https://madebyevan.com/webgl-water) ... and yeah, and co-founded [Figma](https://www.figma.com/)!
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
3
11
|
```bash
|
|
4
12
|
npm install @tmbr/bundler --save-dev
|
|
5
13
|
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
`@tmbr/bundler` has two commands - `build` and `watch` - that both create concurrent builds:
|
|
17
|
+
- `build/main.dev.[css|js]` development version with sourcemaps
|
|
18
|
+
- `build/main.min.[css|js]` minified production version
|
|
19
|
+
|
|
20
|
+
### ``tmbr-bundler build``
|
|
21
|
+
### ``tmbr-bundler watch``
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
More information coming soon!
|
package/cli.js
CHANGED
|
@@ -7,9 +7,9 @@ const server = require('browser-sync').create();
|
|
|
7
7
|
const styles = require('esbuild-sass-plugin').sassPlugin;
|
|
8
8
|
const silent = require('sass').Logger.silent;
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
const src = path.resolve(
|
|
12
|
-
const package = require(`${
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const src = path.resolve(cwd, 'src');
|
|
12
|
+
const package = require(`${cwd}/package.json`);
|
|
13
13
|
const command = process.argv[2];
|
|
14
14
|
|
|
15
15
|
if (!['build', 'watch'].includes(command)) {
|
|
@@ -32,10 +32,11 @@ const logger = (options = {}) => ({
|
|
|
32
32
|
if (result.warnings.length || result.errors.length) return console.log('\007');
|
|
33
33
|
|
|
34
34
|
const css = `${path}/${slug}.css`;
|
|
35
|
-
console.log(`${css} ${Math.round(fs.statSync(css).size / 1000)} KB`);
|
|
36
|
-
|
|
37
35
|
const js = `${path}/${slug}.js`;
|
|
36
|
+
|
|
37
|
+
console.log(`${css} ${Math.round(fs.statSync(css).size / 1000)} KB`);
|
|
38
38
|
console.log(`${js} ${Math.round(fs.statSync(js).size / 1000)} KB`);
|
|
39
|
+
console.log()
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
});
|
|
@@ -108,4 +109,17 @@ async function main() {
|
|
|
108
109
|
});
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
function extend(options, config) {
|
|
113
|
+
if (!config) return options;
|
|
114
|
+
return typeof config === 'function' ? config(options) : Object.assign(options, config);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (fs.existsSync(process.argv[3])) {
|
|
118
|
+
const test = require(`${cwd}/${process.argv[3]}`);
|
|
119
|
+
console.log(extend(watchOptions, test.watch));
|
|
120
|
+
console.log(extend(buildOptions, test.build));
|
|
121
|
+
console.log(extend(serveOptions, test.serve));
|
|
122
|
+
process.exit();
|
|
123
|
+
}
|
|
124
|
+
|
|
111
125
|
main();
|