@tmbr/bundler 1.5.1 → 1.6.0

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.
Files changed (2) hide show
  1. package/cli.js +7 -30
  2. package/package.json +2 -2
package/cli.js CHANGED
@@ -1,5 +1,6 @@
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;
5
6
  const chalk = require('chalk');
@@ -42,21 +43,11 @@ function entryPoints(suffix = '') {
42
43
  });
43
44
 
44
45
  return entries.reduce((result, [name, path]) => {
45
- result[`${name}${suffix}`] = path;
46
+ if (fs.existsSync(path)) result[`${name}${suffix}`] = path;
46
47
  return result;
47
48
  }, {});
48
49
  }
49
50
 
50
- const assets = (options = {}) => ({
51
- name: 'assets',
52
- setup(build) {
53
- build.onResolve({filter: /..\/(assets|fonts|images)\//}, args => ({
54
- path: args.path,
55
- external: true
56
- }))
57
- },
58
- });
59
-
60
51
  const errors = (options = {}) => ({
61
52
  name: 'errors',
62
53
  setup(build) {
@@ -68,18 +59,17 @@ const errors = (options = {}) => ({
68
59
 
69
60
  const defaults = {
70
61
  watch: command === 'watch',
62
+ alias: {'~': path.resolve(dir, 'src')},
71
63
  outdir: path.resolve(dir, 'build'),
72
64
  bundle: true,
73
65
  minify: true,
66
+ external: ['../assets/*', '../fonts/*', '../images/*'],
74
67
  sourcemap: false,
75
68
  logLevel: 'warning',
76
69
  legalComments: 'none',
77
70
  treeShaking: true,
78
71
  target: 'es2019',
79
- plugins: [
80
- styles({sourceMap: true}),
81
- assets(),
82
- ],
72
+ plugins: [styles({sourceMap: true})],
83
73
  };
84
74
 
85
75
  const watchConfig = Object.assign({}, defaults, {
@@ -87,10 +77,7 @@ const watchConfig = Object.assign({}, defaults, {
87
77
  minify: false,
88
78
  sourcemap: 'inline',
89
79
  logLevel: 'silent',
90
- plugins: [
91
- ...defaults.plugins,
92
- errors()
93
- ],
80
+ plugins: [...defaults.plugins, errors()],
94
81
  });
95
82
 
96
83
  const buildConfig = Object.assign({}, defaults, {
@@ -103,24 +90,14 @@ esbuild.build(buildConfig).catch(noop);
103
90
 
104
91
  if (command === 'watch') {
105
92
 
106
- const watchedBuilds = Object.keys(watchConfig.entryPoints).map(name => (
107
- `${watchConfig.outdir}/${name}.*`
108
- ));
109
-
110
- const files = [
111
- ...watchedBuilds,
112
- 'images/*',
113
- '**/*.php'
114
- ];
115
-
116
93
  const options = {
117
94
  proxy: `${package.name}.test`,
95
+ files: ['build/*', '**/*.php'],
118
96
  host: 'localhost',
119
97
  open: false,
120
98
  notify: false,
121
99
  logLevel: 'silent',
122
100
  ui: false,
123
- files
124
101
  };
125
102
 
126
103
  server.init(options, ok);
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.1",
4
+ "version": "1.6.0",
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",
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "browser-sync": "^2.27.10",
13
13
  "chalk": "^4.1.2",
14
- "esbuild": "^0.15.5",
14
+ "esbuild": "^0.16.10",
15
15
  "esbuild-sass-plugin": "^2.3.2",
16
16
  "qrcode-terminal": "^0.12.0"
17
17
  }