@roots/bud-build 5.7.6 → 5.8.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/lib/cjs/Build/config/builder.js +15 -46
- package/lib/cjs/Build/config/filenameFormat.js +4 -4
- package/lib/cjs/Build/index.js +25 -43
- package/lib/cjs/Item/index.js +9 -6
- package/lib/cjs/Loader/index.js +8 -5
- package/lib/cjs/Rule/index.js +28 -15
- package/lib/cjs/index.js +14 -14
- package/lib/cjs/{Build/items.js → items.js} +14 -7
- 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 +37 -11
- 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 +11 -17
- package/types/Build/index.d.ts.map +1 -1
- package/types/Item/index.d.ts +15 -14
- 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
|
*
|
|
@@ -175,7 +164,7 @@ class Build extends Framework.Service {
|
|
|
175
164
|
* @decorator `@bind`
|
|
176
165
|
*/
|
|
177
166
|
makeRule(options) {
|
|
178
|
-
return new Rule_1.
|
|
167
|
+
return new Rule_1.default(() => this.app, options);
|
|
179
168
|
}
|
|
180
169
|
/**
|
|
181
170
|
* Set a rule
|
|
@@ -201,7 +190,7 @@ class Build extends Framework.Service {
|
|
|
201
190
|
* @decorator `@bind`
|
|
202
191
|
*/
|
|
203
192
|
makeLoader(options) {
|
|
204
|
-
return new Loader_1.
|
|
193
|
+
return new Loader_1.default(() => this.app, options);
|
|
205
194
|
}
|
|
206
195
|
/**
|
|
207
196
|
* Set a rule
|
|
@@ -230,7 +219,7 @@ class Build extends Framework.Service {
|
|
|
230
219
|
* @decorator `@bind`
|
|
231
220
|
*/
|
|
232
221
|
makeItem(options) {
|
|
233
|
-
return new Item_1.
|
|
222
|
+
return new Item_1.default(() => this.app, options);
|
|
234
223
|
}
|
|
235
224
|
/**
|
|
236
225
|
* Write final configuration to storage directory
|
|
@@ -255,13 +244,6 @@ __decorate([
|
|
|
255
244
|
__decorate([
|
|
256
245
|
bud_support_1.bind
|
|
257
246
|
], 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
247
|
__decorate([
|
|
266
248
|
bud_support_1.bind
|
|
267
249
|
], 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
|
-
* {@inheritDoc @roots/
|
|
32
|
+
* {@inheritDoc @roots/Bud-Bud#Item.Abstract.getLoader}
|
|
30
33
|
*
|
|
31
34
|
* @public
|
|
32
35
|
* @decorator `@bind`
|
|
@@ -100,4 +103,4 @@ __decorate([
|
|
|
100
103
|
__decorate([
|
|
101
104
|
bud_support_1.bind
|
|
102
105
|
], Item.prototype, "toWebpack", null);
|
|
103
|
-
exports.
|
|
106
|
+
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`
|
|
@@ -95,22 +98,27 @@ class Rule extends Base_1.Base {
|
|
|
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
|
|
@@ -239,4 +252,4 @@ __decorate([
|
|
|
239
252
|
__decorate([
|
|
240
253
|
bud_support_1.bind
|
|
241
254
|
], Rule.prototype, "toWebpack", null);
|
|
242
|
-
exports.
|
|
255
|
+
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
|
*
|
|
@@ -11,7 +11,7 @@ const css = (app) => app.build
|
|
|
11
11
|
.setLoader(`css`)
|
|
12
12
|
.setOptions(({ hooks }) => ({
|
|
13
13
|
importLoaders: 1,
|
|
14
|
-
sourceMap: hooks.filter('build.devtool')
|
|
14
|
+
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
15
15
|
}));
|
|
16
16
|
exports.css = css;
|
|
17
17
|
/**
|
|
@@ -26,7 +26,7 @@ const cssModule = (app) => app.build
|
|
|
26
26
|
importLoaders: 1,
|
|
27
27
|
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
28
28
|
modules: true,
|
|
29
|
-
sourceMap: hooks.filter('build.devtool')
|
|
29
|
+
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
30
30
|
}));
|
|
31
31
|
exports.cssModule = cssModule;
|
|
32
32
|
/**
|
|
@@ -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
|
/**
|
|
@@ -95,7 +95,7 @@ const resolveUrl = (app) => app.build
|
|
|
95
95
|
.setLoader(`resolveUrl`)
|
|
96
96
|
.setOptions(({ path, hooks }) => ({
|
|
97
97
|
root: path('@src'),
|
|
98
|
-
sourceMap: hooks.filter('build.devtool')
|
|
98
|
+
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
99
99
|
}));
|
|
100
100
|
exports.resolveUrl = resolveUrl;
|
|
101
101
|
/**
|
|
@@ -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;
|