@roots/bud-build 5.7.7 → 5.8.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/lib/cjs/Build/config/builder.js +15 -46
- package/lib/cjs/Build/config/filenameFormat.js +4 -4
- package/lib/cjs/Build/index.js +44 -59
- package/lib/cjs/Item/index.js +28 -11
- package/lib/cjs/Loader/index.js +8 -5
- package/lib/cjs/Rule/index.js +37 -22
- package/lib/cjs/index.js +14 -14
- package/lib/cjs/{Build/items.js → items.js} +11 -4
- package/lib/cjs/{Build/loaders.js → loaders.js} +3 -1
- package/lib/cjs/rules.js +195 -0
- package/lib/cjs/shared/Base.js +13 -2
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -15
- package/types/Build/config/builder.d.ts +4 -4
- package/types/Build/config/builder.d.ts.map +1 -1
- package/types/Build/config/filenameFormat.d.ts +3 -3
- package/types/Build/config/filenameFormat.d.ts.map +1 -1
- package/types/Build/index.d.ts +26 -32
- package/types/Build/index.d.ts.map +1 -1
- package/types/Item/index.d.ts +30 -15
- package/types/Item/index.d.ts.map +1 -1
- package/types/Loader/index.d.ts +9 -8
- package/types/Loader/index.d.ts.map +1 -1
- package/types/Rule/index.d.ts +29 -30
- package/types/Rule/index.d.ts.map +1 -1
- package/types/index.d.ts +9 -9
- package/types/index.d.ts.map +1 -1
- package/types/items.d.ts +73 -0
- package/types/items.d.ts.map +1 -0
- package/types/loaders.d.ts +47 -0
- package/types/loaders.d.ts.map +1 -0
- package/types/rules.d.ts +84 -0
- package/types/rules.d.ts.map +1 -0
- package/types/shared/Base.d.ts +7 -7
- package/types/shared/Base.d.ts.map +1 -1
- package/lib/cjs/Build/config/builder.unwrap.js +0 -35
- package/lib/cjs/Build/rules.js +0 -174
- package/types/Build/config/builder.unwrap.d.ts +0 -19
- package/types/Build/config/builder.unwrap.d.ts.map +0 -1
- package/types/Build/items.d.ts +0 -67
- package/types/Build/items.d.ts.map +0 -1
- package/types/Build/loaders.d.ts +0 -46
- package/types/Build/loaders.d.ts.map +0 -1
- package/types/Build/rules.d.ts +0 -84
- package/types/Build/rules.d.ts.map +0 -1
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.build = void 0;
|
|
4
|
-
const builder_unwrap_1 = require("./builder.unwrap");
|
|
5
4
|
const filenameFormat_1 = require("./filenameFormat");
|
|
6
5
|
/**
|
|
7
6
|
* Initializes configuration builder hooks
|
|
8
7
|
*
|
|
9
8
|
* @remarks
|
|
10
9
|
* All hooks in the `build` namespace are initialized here with
|
|
11
|
-
* the exception of `build.cache` which is handled in {@link
|
|
10
|
+
* the exception of `build.cache` which is handled in {@link Bud.cache}
|
|
12
11
|
*
|
|
13
|
-
* @param app - the
|
|
12
|
+
* @param app - the Bud instance
|
|
14
13
|
* @returns Promise
|
|
15
14
|
*
|
|
16
15
|
* @public
|
|
17
16
|
*/
|
|
18
17
|
async function build(app) {
|
|
19
|
-
/**
|
|
20
|
-
* App bound unwrap
|
|
21
|
-
*/
|
|
22
|
-
const unwrap = builder_unwrap_1.unwrap.bind(app);
|
|
23
18
|
app.hooks
|
|
24
|
-
.on('build.
|
|
19
|
+
.on('build.bail', () => app.isProduction)
|
|
20
|
+
.hooks.on('build.cache', () => app.cache.configuration)
|
|
25
21
|
.hooks.on('build.context', () => app.context.projectDir)
|
|
26
|
-
.hooks.on('build.
|
|
22
|
+
.hooks.on('build.infrastructureLogging', () => ({
|
|
23
|
+
console: app.hooks.filter('build.infrastructureLogging.console'),
|
|
24
|
+
level: app.hooks.filter('build.infrastructureLogging.level'),
|
|
25
|
+
}))
|
|
26
|
+
.hooks.on('build.mode', () => app.mode)
|
|
27
27
|
.hooks.on('build.module', () => ({
|
|
28
28
|
noParse: app.hooks.filter('build.module.noParse'),
|
|
29
29
|
rules: app.hooks.filter('build.module.rules'),
|
|
@@ -46,6 +46,10 @@ async function build(app) {
|
|
|
46
46
|
path: app.hooks.filter('build.output.path'),
|
|
47
47
|
pathinfo: app.hooks.filter('build.output.pathinfo'),
|
|
48
48
|
publicPath: app.hooks.filter('build.output.publicPath'),
|
|
49
|
+
}))
|
|
50
|
+
.hooks.async('build.resolve.alias', async () => ({
|
|
51
|
+
'@src': app.path('@src'),
|
|
52
|
+
'@dist': app.path('@dist'),
|
|
49
53
|
}))
|
|
50
54
|
.hooks.on('build.output.assetModuleFilename', () => (0, filenameFormat_1.filenameFormat)(app, '[ext]'))
|
|
51
55
|
.hooks.on('build.output.chunkFilename', () => (0, filenameFormat_1.filenameFormat)(app))
|
|
@@ -76,42 +80,7 @@ async function build(app) {
|
|
|
76
80
|
})
|
|
77
81
|
.hooks.on('build.target', () => app.project.has('manifest.browserslist') &&
|
|
78
82
|
app.project.isArray('manifest.browserslist')
|
|
79
|
-
? `browserslist:${app.path('package.json')}`
|
|
80
|
-
: undefined)
|
|
81
|
-
.hooks.on('build.infrastructureLogging', () => ({
|
|
82
|
-
console: app.hooks.filter('build.infrastructureLogging.console'),
|
|
83
|
-
}));
|
|
84
|
-
/**
|
|
85
|
-
* Safe
|
|
86
|
-
*/
|
|
87
|
-
app.hooks
|
|
88
|
-
.on('build.bail', unwrap('build.bail'))
|
|
89
|
-
.hooks.on('build.devtool', unwrap('build.devtool'))
|
|
90
|
-
.hooks.on('build.loader', unwrap('build.loader'))
|
|
91
|
-
.hooks.on('build.module.rules.before', unwrap('build.module.rules.before'))
|
|
92
|
-
.hooks.on('build.module.rules.after', unwrap('build.module.rules.after'))
|
|
93
|
-
.hooks.on('build.module.unsafeCache', unwrap('build.module.unsafeCache'))
|
|
94
|
-
.hooks.on('build.module.noParse', unwrap('build.module.noParse'))
|
|
95
|
-
.hooks.on('build.infrastructureLogging.level', unwrap('build.infrastructureLogging.level'))
|
|
96
|
-
.hooks.on('build.infrastructureLogging.console', unwrap('build.infrastructureLogging.console'))
|
|
97
|
-
.hooks.on('build.node', unwrap('build.node'))
|
|
98
|
-
.hooks.on('build.optimization.emitOnErrors', unwrap('build.optimization.emitOnErrors'))
|
|
99
|
-
.hooks.on('build.optimization.minimize', unwrap('build.optimization.minimize'))
|
|
100
|
-
.hooks.on('build.optimization.minimizer', unwrap('build.optimization.minimizer'))
|
|
101
|
-
.hooks.on('build.optimization.moduleIds', unwrap('build.optimization.moduleIds'))
|
|
102
|
-
.hooks.on('build.optimization.removeEmptyChunks', unwrap('build.optimization.removeEmptyChunks'))
|
|
103
|
-
.hooks.on('build.optimization.runtimeChunk', unwrap('build.optimization.runtimeChunk'))
|
|
104
|
-
.hooks.on('build.optimization.splitChunks', unwrap('build.optimization.splitChunks'))
|
|
105
|
-
.hooks.on('build.output.clean', unwrap('build.output.clean'))
|
|
106
|
-
.hooks.on('build.output.pathinfo', unwrap('build.output.pathinfo'))
|
|
107
|
-
.hooks.on('build.output.publicPath', unwrap('build.output.publicPath', 'auto'))
|
|
108
|
-
.hooks.on('build.parallelism', unwrap('build.parallelism'))
|
|
109
|
-
.hooks.on('build.performance', unwrap('build.performance'))
|
|
110
|
-
.hooks.on('build.profile', unwrap('build.profile'))
|
|
111
|
-
.hooks.async('build.resolve.alias', unwrap('build.resolve.alias'))
|
|
112
|
-
.hooks.on('build.resolve.extensions', unwrap('build.resolve.extensions'))
|
|
113
|
-
.hooks.on('build.stats', unwrap('build.stats'))
|
|
114
|
-
.hooks.on('build.watch', unwrap('build.watch'))
|
|
115
|
-
.hooks.on('build.watchOptions', unwrap('build.watchOptions'));
|
|
83
|
+
? `browserslist:${app.path('./package.json')}`
|
|
84
|
+
: undefined);
|
|
116
85
|
}
|
|
117
86
|
exports.build = build;
|
|
@@ -4,14 +4,14 @@ exports.filenameFormat = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Filename
|
|
6
6
|
*
|
|
7
|
-
* @param app -
|
|
7
|
+
* @param app - Bud
|
|
8
8
|
* @param ext - Filename extension
|
|
9
9
|
*
|
|
10
10
|
* @returns filename format
|
|
11
11
|
*
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
|
-
const filenameFormat = (app, ext) => app.
|
|
15
|
-
? app.
|
|
16
|
-
: app.
|
|
14
|
+
const filenameFormat = (app, ext) => app.hooks.filter('feature.hash')
|
|
15
|
+
? app.hooks.filter('value.hashFormat').concat(ext ?? '.js')
|
|
16
|
+
: app.hooks.filter('value.fileFormat').concat(ext ?? '.js');
|
|
17
17
|
exports.filenameFormat = filenameFormat;
|
package/lib/cjs/Build/index.js
CHANGED
|
@@ -28,18 +28,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
__setModuleDefault(result, mod);
|
|
29
29
|
return result;
|
|
30
30
|
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
31
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
35
|
exports.Build = void 0;
|
|
33
|
-
const
|
|
36
|
+
const Bud = __importStar(require("@roots/bud-framework"));
|
|
34
37
|
const bud_support_1 = require("@roots/bud-support");
|
|
35
38
|
const lodash_1 = require("lodash");
|
|
36
|
-
const Item_1 = require("../Item");
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
+
const Item_1 = __importDefault(require("../Item"));
|
|
40
|
+
const items = __importStar(require("../items"));
|
|
41
|
+
const Loader_1 = __importDefault(require("../Loader"));
|
|
42
|
+
const loaders = __importStar(require("../loaders"));
|
|
43
|
+
const Rule_1 = __importDefault(require("../Rule"));
|
|
44
|
+
const rules = __importStar(require("../rules"));
|
|
39
45
|
const config = __importStar(require("./config"));
|
|
40
|
-
const items = __importStar(require("./items"));
|
|
41
|
-
const loaders = __importStar(require("./loaders"));
|
|
42
|
-
const rules = __importStar(require("./rules"));
|
|
43
46
|
const { isUndefined } = bud_support_1.lodash;
|
|
44
47
|
const { ensureFile, writeFile } = bud_support_1.fs;
|
|
45
48
|
/**
|
|
@@ -47,7 +50,7 @@ const { ensureFile, writeFile } = bud_support_1.fs;
|
|
|
47
50
|
*
|
|
48
51
|
* @public
|
|
49
52
|
*/
|
|
50
|
-
class Build extends
|
|
53
|
+
class Build extends Bud.Service {
|
|
51
54
|
constructor() {
|
|
52
55
|
super(...arguments);
|
|
53
56
|
/**
|
|
@@ -62,10 +65,7 @@ class Build extends Framework.Service {
|
|
|
62
65
|
* @decorator `@bind`
|
|
63
66
|
*/
|
|
64
67
|
async registered() {
|
|
65
|
-
this.app.hooks
|
|
66
|
-
.action('event.build.before', async (app) => app.time(`build.make`))
|
|
67
|
-
.hooks.action('event.build.after', async (app) => app.timeEnd(`build.make`))
|
|
68
|
-
.hooks.action('event.build.after', this.writeFinalConfig);
|
|
68
|
+
this.app.hooks.action('event.build.after', this.writeFinalConfig);
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
71
|
* Make webpack configuration
|
|
@@ -76,7 +76,7 @@ class Build extends Framework.Service {
|
|
|
76
76
|
async make() {
|
|
77
77
|
await this.app.hooks.fire('event.build.before');
|
|
78
78
|
await Promise.all([
|
|
79
|
-
['entry'
|
|
79
|
+
['entry'],
|
|
80
80
|
['plugins', true],
|
|
81
81
|
['resolve', true],
|
|
82
82
|
['bail'],
|
|
@@ -101,29 +101,18 @@ class Build extends Framework.Service {
|
|
|
101
101
|
['target'],
|
|
102
102
|
['watch'],
|
|
103
103
|
['watchOptions'],
|
|
104
|
-
]
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
].map(async ([propKey, isAsync]) => {
|
|
105
|
+
const propValue = isAsync === true
|
|
106
|
+
? await this.app.hooks.filterAsync(`build.${propKey}`)
|
|
107
|
+
: this.app.hooks.filter(`build.${propKey}`);
|
|
108
|
+
if (isUndefined(propValue))
|
|
109
|
+
return;
|
|
110
|
+
Object.assign(this.config, { [propKey]: propValue });
|
|
111
|
+
return Promise.resolve();
|
|
112
|
+
}));
|
|
108
113
|
await this.app.hooks.fire('event.build.after');
|
|
109
114
|
return this.config;
|
|
110
115
|
}
|
|
111
|
-
memoMap(...args) {
|
|
112
|
-
const [[key, ...rest]] = args;
|
|
113
|
-
if (!this.app.hooks.has(`build.${key}`))
|
|
114
|
-
return false;
|
|
115
|
-
const type = rest.length && rest.shift() ? true : false;
|
|
116
|
-
const count = this.app.hooks.count(`build.${key}`);
|
|
117
|
-
return [key, type, count];
|
|
118
|
-
}
|
|
119
|
-
async memoMapValue([propKey, isAsync, _count]) {
|
|
120
|
-
const propValue = isAsync === true
|
|
121
|
-
? await this.app.hooks.filterAsync(`build.${propKey}`)
|
|
122
|
-
: this.app.hooks.filter(`build.${propKey}`);
|
|
123
|
-
if (isUndefined(propValue))
|
|
124
|
-
return;
|
|
125
|
-
Object.assign(this.config, { [propKey]: propValue });
|
|
126
|
-
}
|
|
127
116
|
/**
|
|
128
117
|
* Service register event
|
|
129
118
|
*
|
|
@@ -152,21 +141,24 @@ class Build extends Framework.Service {
|
|
|
152
141
|
await config.builder.build(this.app);
|
|
153
142
|
}
|
|
154
143
|
/**
|
|
155
|
-
* Set
|
|
144
|
+
* Set Rule
|
|
156
145
|
*
|
|
157
|
-
* @param name -
|
|
158
|
-
* @param options -
|
|
159
|
-
* @returns the
|
|
146
|
+
* @param name - Rule key
|
|
147
|
+
* @param options - Rule constructor properties
|
|
148
|
+
* @returns the Rule
|
|
160
149
|
*
|
|
161
150
|
* @public
|
|
162
151
|
* @decorator `@bind`
|
|
163
152
|
*/
|
|
164
153
|
setRule(name, options) {
|
|
165
|
-
|
|
154
|
+
const processedOptions = (0, lodash_1.isFunction)(options)
|
|
155
|
+
? options(this.makeRule())
|
|
156
|
+
: this.makeRule(options);
|
|
157
|
+
Object.assign(this.rules, { [name]: processedOptions });
|
|
166
158
|
return this;
|
|
167
159
|
}
|
|
168
160
|
/**
|
|
169
|
-
* Make
|
|
161
|
+
* Make Rule
|
|
170
162
|
*
|
|
171
163
|
* @param options - rule constructor properties
|
|
172
164
|
* @returns the rule
|
|
@@ -175,14 +167,14 @@ class Build extends Framework.Service {
|
|
|
175
167
|
* @decorator `@bind`
|
|
176
168
|
*/
|
|
177
169
|
makeRule(options) {
|
|
178
|
-
return new Rule_1.
|
|
170
|
+
return new Rule_1.default(() => this.app, options);
|
|
179
171
|
}
|
|
180
172
|
/**
|
|
181
|
-
* Set
|
|
173
|
+
* Set Loader
|
|
182
174
|
*
|
|
183
|
-
* @param name -
|
|
184
|
-
* @param options -
|
|
185
|
-
* @returns the
|
|
175
|
+
* @param name - Loader key
|
|
176
|
+
* @param options - Loader constructor properties
|
|
177
|
+
* @returns the Loader
|
|
186
178
|
*
|
|
187
179
|
* @public
|
|
188
180
|
* @decorator `@bind`
|
|
@@ -192,7 +184,7 @@ class Build extends Framework.Service {
|
|
|
192
184
|
return this;
|
|
193
185
|
}
|
|
194
186
|
/**
|
|
195
|
-
* Make
|
|
187
|
+
* Make Loader
|
|
196
188
|
*
|
|
197
189
|
* @param options - rule constructor properties
|
|
198
190
|
* @returns the rule
|
|
@@ -201,14 +193,14 @@ class Build extends Framework.Service {
|
|
|
201
193
|
* @decorator `@bind`
|
|
202
194
|
*/
|
|
203
195
|
makeLoader(options) {
|
|
204
|
-
return new Loader_1.
|
|
196
|
+
return new Loader_1.default(() => this.app, options);
|
|
205
197
|
}
|
|
206
198
|
/**
|
|
207
|
-
* Set
|
|
199
|
+
* Set Item
|
|
208
200
|
*
|
|
209
|
-
* @param name -
|
|
210
|
-
* @param options -
|
|
211
|
-
* @returns the
|
|
201
|
+
* @param name - Item key
|
|
202
|
+
* @param options - Item constructor properties
|
|
203
|
+
* @returns the Item
|
|
212
204
|
*
|
|
213
205
|
* @public
|
|
214
206
|
* @decorator `@bind`
|
|
@@ -221,7 +213,7 @@ class Build extends Framework.Service {
|
|
|
221
213
|
return this;
|
|
222
214
|
}
|
|
223
215
|
/**
|
|
224
|
-
* Make
|
|
216
|
+
* Make Item
|
|
225
217
|
*
|
|
226
218
|
* @param options - rule constructor properties
|
|
227
219
|
* @returns the rule
|
|
@@ -230,7 +222,7 @@ class Build extends Framework.Service {
|
|
|
230
222
|
* @decorator `@bind`
|
|
231
223
|
*/
|
|
232
224
|
makeItem(options) {
|
|
233
|
-
return new Item_1.
|
|
225
|
+
return new Item_1.default(() => this.app, options);
|
|
234
226
|
}
|
|
235
227
|
/**
|
|
236
228
|
* Write final configuration to storage directory
|
|
@@ -255,13 +247,6 @@ __decorate([
|
|
|
255
247
|
__decorate([
|
|
256
248
|
bud_support_1.bind
|
|
257
249
|
], Build.prototype, "make", null);
|
|
258
|
-
__decorate([
|
|
259
|
-
bud_support_1.bind
|
|
260
|
-
], Build.prototype, "memoMap", null);
|
|
261
|
-
__decorate([
|
|
262
|
-
bud_support_1.bind,
|
|
263
|
-
(0, bud_support_1.memo)()
|
|
264
|
-
], Build.prototype, "memoMapValue", null);
|
|
265
250
|
__decorate([
|
|
266
251
|
bud_support_1.bind
|
|
267
252
|
], Build.prototype, "register", null);
|
package/lib/cjs/Item/index.js
CHANGED
|
@@ -5,20 +5,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
12
|
+
exports.default = void 0;
|
|
10
13
|
const bud_support_1 = require("@roots/bud-support");
|
|
11
|
-
const Base_1 = require("../shared/Base");
|
|
14
|
+
const Base_1 = __importDefault(require("../shared/Base"));
|
|
12
15
|
/**
|
|
13
16
|
* Item class
|
|
14
17
|
*
|
|
15
18
|
* @public
|
|
16
19
|
*/
|
|
17
|
-
class Item extends Base_1.
|
|
20
|
+
class Item extends Base_1.default {
|
|
18
21
|
/**
|
|
19
22
|
* Class constructor
|
|
20
23
|
*
|
|
21
|
-
* @param options - {@link
|
|
24
|
+
* @param options - {@link Build.Item.Options}
|
|
22
25
|
*/
|
|
23
26
|
constructor(_app, options) {
|
|
24
27
|
super(_app);
|
|
@@ -26,7 +29,7 @@ class Item extends Base_1.Base {
|
|
|
26
29
|
options?.options && this.setOptions(options.options);
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* Get rule set item loader
|
|
30
33
|
*
|
|
31
34
|
* @public
|
|
32
35
|
* @decorator `@bind`
|
|
@@ -35,6 +38,8 @@ class Item extends Base_1.Base {
|
|
|
35
38
|
return this.app.build.loaders[this.unwrap(this.loader)];
|
|
36
39
|
}
|
|
37
40
|
/**
|
|
41
|
+
* Set rule set item loader
|
|
42
|
+
*
|
|
38
43
|
* @public
|
|
39
44
|
* @decorator `@bind`
|
|
40
45
|
*/
|
|
@@ -43,6 +48,17 @@ class Item extends Base_1.Base {
|
|
|
43
48
|
return this;
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
51
|
+
* Get rule set item options
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
54
|
+
* @decorator `@bind`
|
|
55
|
+
*/
|
|
56
|
+
getOptions() {
|
|
57
|
+
return this.unwrap(this.options);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Set rule set item options
|
|
61
|
+
*
|
|
46
62
|
* @public
|
|
47
63
|
* @decorator `@bind`
|
|
48
64
|
*/
|
|
@@ -50,10 +66,9 @@ class Item extends Base_1.Base {
|
|
|
50
66
|
this.options = this.wrap(options);
|
|
51
67
|
return this;
|
|
52
68
|
}
|
|
53
|
-
getOptions() {
|
|
54
|
-
return this.unwrap(this.options);
|
|
55
|
-
}
|
|
56
69
|
/**
|
|
70
|
+
* Merge rule set item options
|
|
71
|
+
*
|
|
57
72
|
* @public
|
|
58
73
|
* @decorator `@bind`
|
|
59
74
|
*/
|
|
@@ -66,6 +81,8 @@ class Item extends Base_1.Base {
|
|
|
66
81
|
return this;
|
|
67
82
|
}
|
|
68
83
|
/**
|
|
84
|
+
* Produce rule set item object for Webpack
|
|
85
|
+
*
|
|
69
86
|
* @public
|
|
70
87
|
* @decorator `@bind`
|
|
71
88
|
*/
|
|
@@ -90,14 +107,14 @@ __decorate([
|
|
|
90
107
|
], Item.prototype, "setLoader", null);
|
|
91
108
|
__decorate([
|
|
92
109
|
bud_support_1.bind
|
|
93
|
-
], Item.prototype, "
|
|
110
|
+
], Item.prototype, "getOptions", null);
|
|
94
111
|
__decorate([
|
|
95
112
|
bud_support_1.bind
|
|
96
|
-
], Item.prototype, "
|
|
113
|
+
], Item.prototype, "setOptions", null);
|
|
97
114
|
__decorate([
|
|
98
115
|
bud_support_1.bind
|
|
99
116
|
], Item.prototype, "mergeOptions", null);
|
|
100
117
|
__decorate([
|
|
101
118
|
bud_support_1.bind
|
|
102
119
|
], Item.prototype, "toWebpack", null);
|
|
103
|
-
exports.
|
|
120
|
+
exports.default = Item;
|
package/lib/cjs/Loader/index.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const Base_1 = require("../shared/Base");
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const Base_1 = __importDefault(require("../shared/Base"));
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Bud Loader
|
|
7
10
|
*
|
|
8
11
|
* @public
|
|
9
12
|
*/
|
|
10
|
-
class Loader extends Base_1.
|
|
13
|
+
class Loader extends Base_1.default {
|
|
11
14
|
/**
|
|
12
15
|
* Class constructor
|
|
13
16
|
*
|
|
@@ -27,4 +30,4 @@ class Loader extends Base_1.Base {
|
|
|
27
30
|
return this;
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
|
-
exports.
|
|
33
|
+
exports.default = Loader;
|
package/lib/cjs/Rule/index.js
CHANGED
|
@@ -5,17 +5,20 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
12
|
+
exports.default = void 0;
|
|
10
13
|
const bud_support_1 = require("@roots/bud-support");
|
|
11
|
-
const Base_1 = require("../shared/Base");
|
|
14
|
+
const Base_1 = __importDefault(require("../shared/Base"));
|
|
12
15
|
const { isFunction, isString } = bud_support_1.lodash;
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
17
|
+
* Bud Rule
|
|
15
18
|
*
|
|
16
19
|
* @public
|
|
17
20
|
*/
|
|
18
|
-
class Rule extends Base_1.
|
|
21
|
+
class Rule extends Base_1.default {
|
|
19
22
|
/**
|
|
20
23
|
* Class constructor
|
|
21
24
|
*
|
|
@@ -36,7 +39,7 @@ class Rule extends Base_1.Base {
|
|
|
36
39
|
/**
|
|
37
40
|
* Test value
|
|
38
41
|
*
|
|
39
|
-
* @param app -
|
|
42
|
+
* @param app - Bud instance
|
|
40
43
|
*
|
|
41
44
|
* @public
|
|
42
45
|
* @decorator `@bind`
|
|
@@ -89,28 +92,33 @@ class Rule extends Base_1.Base {
|
|
|
89
92
|
* @decorator `@bind`
|
|
90
93
|
*/
|
|
91
94
|
setUse(input) {
|
|
92
|
-
this.use =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
this.use = isFunction(input)
|
|
96
|
+
? input(this.getUse() ?? [], this.app)
|
|
97
|
+
: input;
|
|
95
98
|
return this;
|
|
96
99
|
}
|
|
97
100
|
/**
|
|
98
|
-
* Get
|
|
101
|
+
* Get include value
|
|
99
102
|
*
|
|
100
103
|
* @public
|
|
101
104
|
* @decorator `@bind`
|
|
102
105
|
*/
|
|
103
106
|
getInclude() {
|
|
104
|
-
return this.
|
|
107
|
+
return this.include.map(this.unwrap);
|
|
105
108
|
}
|
|
106
109
|
/**
|
|
107
|
-
* Set
|
|
110
|
+
* Set include value
|
|
108
111
|
*
|
|
109
112
|
* @public
|
|
110
113
|
* @decorator `@bind`
|
|
111
114
|
*/
|
|
112
|
-
setInclude(
|
|
113
|
-
|
|
115
|
+
setInclude(includes) {
|
|
116
|
+
if (!this.include)
|
|
117
|
+
this.include = [];
|
|
118
|
+
if (typeof includes === 'function')
|
|
119
|
+
this.include = includes(this.include);
|
|
120
|
+
else
|
|
121
|
+
this.include = includes;
|
|
114
122
|
return this;
|
|
115
123
|
}
|
|
116
124
|
/**
|
|
@@ -120,7 +128,7 @@ class Rule extends Base_1.Base {
|
|
|
120
128
|
* @decorator `@bind`
|
|
121
129
|
*/
|
|
122
130
|
getExclude() {
|
|
123
|
-
return this.
|
|
131
|
+
return this.exclude.map(this.unwrap);
|
|
124
132
|
}
|
|
125
133
|
/**
|
|
126
134
|
* Set exclude value
|
|
@@ -128,8 +136,13 @@ class Rule extends Base_1.Base {
|
|
|
128
136
|
* @public
|
|
129
137
|
* @decorator `@bind`
|
|
130
138
|
*/
|
|
131
|
-
setExclude(
|
|
132
|
-
|
|
139
|
+
setExclude(excludes) {
|
|
140
|
+
if (!this.exclude)
|
|
141
|
+
this.exclude = [];
|
|
142
|
+
if (typeof excludes === 'function')
|
|
143
|
+
this.exclude = excludes(this.exclude);
|
|
144
|
+
else
|
|
145
|
+
this.exclude = excludes;
|
|
133
146
|
return this;
|
|
134
147
|
}
|
|
135
148
|
/**
|
|
@@ -173,7 +186,7 @@ class Rule extends Base_1.Base {
|
|
|
173
186
|
/**
|
|
174
187
|
* Produce final Base output
|
|
175
188
|
*
|
|
176
|
-
* @param app - {@link @roots/bud-framework#
|
|
189
|
+
* @param app - {@link @roots/bud-framework#Bud}
|
|
177
190
|
* @returns finalized rule
|
|
178
191
|
*
|
|
179
192
|
* @public
|
|
@@ -181,16 +194,18 @@ class Rule extends Base_1.Base {
|
|
|
181
194
|
*/
|
|
182
195
|
toWebpack() {
|
|
183
196
|
const output = { test: this.getTest() };
|
|
184
|
-
this.use &&
|
|
185
|
-
Object.assign(output, {
|
|
186
|
-
use: this.getUse().map(item => this.app.build.items[item].toWebpack()),
|
|
187
|
-
});
|
|
188
197
|
this.include && Object.assign(output, { include: this.getInclude() });
|
|
189
198
|
this.exclude && Object.assign(output, { exclude: this.getExclude() });
|
|
190
199
|
this.type && Object.assign(output, { type: this.getType() });
|
|
191
200
|
this.parser && Object.assign(output, { parser: this.getParser() });
|
|
192
201
|
this.generator &&
|
|
193
202
|
Object.assign(output, { generator: this.getGenerator() });
|
|
203
|
+
this.use &&
|
|
204
|
+
Object.assign(output, {
|
|
205
|
+
use: this.getUse()
|
|
206
|
+
.map(item => this.app.build.items[item])
|
|
207
|
+
.map(item => item.toWebpack()),
|
|
208
|
+
});
|
|
194
209
|
return output;
|
|
195
210
|
}
|
|
196
211
|
}
|
|
@@ -239,4 +254,4 @@ __decorate([
|
|
|
239
254
|
__decorate([
|
|
240
255
|
bud_support_1.bind
|
|
241
256
|
], Rule.prototype, "toWebpack", null);
|
|
242
|
-
exports.
|
|
257
|
+
exports.default = Rule;
|
package/lib/cjs/index.js
CHANGED
|
@@ -24,27 +24,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
__setModuleDefault(result, mod);
|
|
25
25
|
return result;
|
|
26
26
|
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
27
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
31
|
exports.rules = exports.loaders = exports.items = exports.Rule = exports.Item = exports.Loader = exports.Build = void 0;
|
|
29
32
|
/**
|
|
30
|
-
*
|
|
33
|
+
* Configuration builder
|
|
31
34
|
*
|
|
32
|
-
* @see https://
|
|
35
|
+
* @see https://bud.js.org
|
|
33
36
|
* @see https://github.com/roots/bud
|
|
34
37
|
*
|
|
35
38
|
* @packageDocumentation
|
|
36
39
|
*/
|
|
37
40
|
var Build_1 = require("./Build");
|
|
38
41
|
Object.defineProperty(exports, "Build", { enumerable: true, get: function () { return Build_1.Build; } });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
exports.
|
|
47
|
-
|
|
48
|
-
exports.loaders = loaders;
|
|
49
|
-
const rules = __importStar(require("./Build/rules"));
|
|
50
|
-
exports.rules = rules;
|
|
42
|
+
const Item_1 = __importDefault(require("./Item"));
|
|
43
|
+
exports.Item = Item_1.default;
|
|
44
|
+
const Loader_1 = __importDefault(require("./Loader"));
|
|
45
|
+
exports.Loader = Loader_1.default;
|
|
46
|
+
const Rule_1 = __importDefault(require("./Rule"));
|
|
47
|
+
exports.Rule = Rule_1.default;
|
|
48
|
+
exports.items = __importStar(require("./items"));
|
|
49
|
+
exports.loaders = __importStar(require("./loaders"));
|
|
50
|
+
exports.rules = __importStar(require("./rules"));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.xml = exports.resolveUrl = exports.file = exports.raw = exports.precss = exports.minicss = exports.md = exports.style = exports.html = exports.csv = exports.cssModule = exports.css = void 0;
|
|
3
|
+
exports.yml = exports.xml = exports.resolveUrl = exports.file = exports.raw = exports.precss = exports.minicss = exports.md = exports.style = exports.html = exports.csv = exports.cssModule = exports.css = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* .css handler factory
|
|
6
6
|
*
|
|
@@ -80,9 +80,9 @@ const file = (app) => app.build
|
|
|
80
80
|
.makeItem()
|
|
81
81
|
.setLoader(`file`)
|
|
82
82
|
.setOptions(app => ({
|
|
83
|
-
name: app.
|
|
84
|
-
? app.
|
|
85
|
-
: app.
|
|
83
|
+
name: app.hooks.filter('feature.hash')
|
|
84
|
+
? app.hooks.filter('value.hashFormat').concat('.[ext]')
|
|
85
|
+
: app.hooks.filter('value.fileFormat').concat('.[ext]'),
|
|
86
86
|
}));
|
|
87
87
|
exports.file = file;
|
|
88
88
|
/**
|
|
@@ -105,3 +105,10 @@ exports.resolveUrl = resolveUrl;
|
|
|
105
105
|
*/
|
|
106
106
|
const xml = (app) => app.build.makeItem().setLoader(`xml`);
|
|
107
107
|
exports.xml = xml;
|
|
108
|
+
/**
|
|
109
|
+
* Factory {@link Item} for yml
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
const yml = (app) => app.build.makeItem().setLoader(`yml`);
|
|
114
|
+
exports.yml = yml;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.xml = exports.url = exports.style = exports.resolveUrl = exports.minicss = exports.md = exports.html = exports.file = exports.csv = exports.css = void 0;
|
|
6
|
+
exports.yml = exports.xml = exports.url = exports.style = exports.resolveUrl = exports.minicss = exports.md = exports.html = exports.file = exports.csv = exports.css = void 0;
|
|
7
7
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
8
8
|
/**
|
|
9
9
|
* css loader
|
|
@@ -59,3 +59,5 @@ exports.url = url;
|
|
|
59
59
|
*/
|
|
60
60
|
const xml = (app) => app.build.makeLoader().setSrc(require.resolve('xml-loader'));
|
|
61
61
|
exports.xml = xml;
|
|
62
|
+
const yml = (app) => app.build.makeLoader().setSrc(require.resolve('js-yaml-loader'));
|
|
63
|
+
exports.yml = yml;
|