@tmbr/bundler 1.5.0 → 1.5.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/cli.js +16 -16
- package/package.json +1 -2
package/cli.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const esbuild = require('esbuild');
|
|
3
|
+
const fs = require('fs');
|
|
3
4
|
const path = require('path');
|
|
4
5
|
const exec = require('child_process').execSync;
|
|
6
|
+
const chalk = require('chalk');
|
|
5
7
|
const styles = require('esbuild-sass-plugin').sassPlugin;
|
|
6
8
|
const qrcode = require('qrcode-terminal');
|
|
7
|
-
const
|
|
8
|
-
const bs = require('browser-sync').create();
|
|
9
|
+
const server = require('browser-sync').create();
|
|
9
10
|
|
|
10
|
-
const
|
|
11
|
-
const package = require(`${
|
|
11
|
+
const dir = process.cwd();
|
|
12
|
+
const package = require(`${dir}/package.json`);
|
|
12
13
|
const command = process.argv[2];
|
|
13
14
|
|
|
14
15
|
if (!['build', 'watch'].includes(command)) {
|
|
@@ -16,16 +17,15 @@ if (!['build', 'watch'].includes(command)) {
|
|
|
16
17
|
process.exit();
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
exec(`rm -rf ${
|
|
20
|
+
exec(`rm -rf ${dir}/build/*`);
|
|
20
21
|
|
|
21
22
|
function ok() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const host = bs.getOption('proxy').get('target');
|
|
25
|
-
const port = bs.getOption('port');
|
|
23
|
+
const host = server.getOption('proxy').get('target');
|
|
24
|
+
const port = server.getOption('port');
|
|
26
25
|
const proxying = `${host}:${port}`;
|
|
27
|
-
const external =
|
|
26
|
+
const external = server.getOption('urls').get('external');
|
|
28
27
|
|
|
28
|
+
console.clear();
|
|
29
29
|
external && qrcode.generate(external, {small: true}, console.log);
|
|
30
30
|
console.log(`Proxying: ${chalk.green(proxying)}`);
|
|
31
31
|
console.log(`External: ${chalk.cyan(external || 'offline')}\n`);
|
|
@@ -38,12 +38,12 @@ function entryPoints(suffix = '') {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const entries = Object.entries({
|
|
41
|
-
admin: path.resolve(
|
|
42
|
-
main: path.resolve(
|
|
41
|
+
admin: path.resolve(dir, './src/admin'),
|
|
42
|
+
main: path.resolve(dir, './src'),
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
return entries.reduce((result, [name, path]) => {
|
|
46
|
-
result[`${name}${suffix}`] = path;
|
|
46
|
+
if (fs.existsSync(path)) result[`${name}${suffix}`] = path;
|
|
47
47
|
return result;
|
|
48
48
|
}, {});
|
|
49
49
|
}
|
|
@@ -51,7 +51,7 @@ function entryPoints(suffix = '') {
|
|
|
51
51
|
const assets = (options = {}) => ({
|
|
52
52
|
name: 'assets',
|
|
53
53
|
setup(build) {
|
|
54
|
-
build.onResolve({filter: /..\/(fonts|images)\//}, args => ({
|
|
54
|
+
build.onResolve({filter: /..\/(assets|fonts|images)\//}, args => ({
|
|
55
55
|
path: args.path,
|
|
56
56
|
external: true
|
|
57
57
|
}))
|
|
@@ -69,7 +69,7 @@ const errors = (options = {}) => ({
|
|
|
69
69
|
|
|
70
70
|
const defaults = {
|
|
71
71
|
watch: command === 'watch',
|
|
72
|
-
outdir: path.resolve(
|
|
72
|
+
outdir: path.resolve(dir, 'build'),
|
|
73
73
|
bundle: true,
|
|
74
74
|
minify: true,
|
|
75
75
|
sourcemap: false,
|
|
@@ -124,5 +124,5 @@ if (command === 'watch') {
|
|
|
124
124
|
files
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
server.init(options, ok);
|
|
128
128
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tmbr/bundler",
|
|
3
3
|
"author": "TMBR (https://wearetmbr.com/)",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "https://github.com/TMBR/tmbr-bundler",
|
|
7
7
|
"description": "WordPress development toolkit built on esbuild and browser-sync",
|
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
"chalk": "^4.1.2",
|
|
14
14
|
"esbuild": "^0.15.5",
|
|
15
15
|
"esbuild-sass-plugin": "^2.3.2",
|
|
16
|
-
"html-entities": "^2.3.3",
|
|
17
16
|
"qrcode-terminal": "^0.12.0"
|
|
18
17
|
}
|
|
19
18
|
}
|