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