@roots/bud-build 6.18.0 → 6.19.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/config/dependencies.js +1 -1
- package/lib/config/entry.js +1 -1
- package/lib/config/module.js +106 -12
- package/lib/config/resolve.js +4 -3
- package/lib/config/resolveLoader.js +14 -8
- package/lib/helpers/registrable.js +1 -1
- package/lib/index.d.ts +7 -3
- package/lib/item/index.js +1 -1
- package/lib/items/index.js +1 -1
- package/lib/registry/index.js +1 -1
- package/lib/rule/index.d.ts +12 -0
- package/lib/rule/index.js +26 -2
- package/lib/service/index.js +2 -2
- package/package.json +6 -6
- package/src/config/dependencies.ts +1 -1
- package/src/config/entry.ts +1 -1
- package/src/config/module.ts +116 -16
- package/src/config/resolve.ts +5 -3
- package/src/config/resolveLoader.ts +8 -2
- package/src/helpers/registrable.ts +1 -1
- package/src/index.ts +7 -3
- package/src/item/index.ts +1 -1
- package/src/items/index.ts +1 -1
- package/src/registry/index.ts +1 -1
- package/src/rule/index.ts +25 -2
- package/src/service/index.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ConfigError } from '@roots/bud-support/errors';
|
|
2
|
-
import isUndefined from '@roots/bud-support/
|
|
2
|
+
import isUndefined from '@roots/bud-support/isUndefined';
|
|
3
3
|
export const dependencies = async ({ hooks, label, root, }) => {
|
|
4
4
|
const dependencies = hooks
|
|
5
5
|
.filter(`build.dependencies`, [])
|
package/lib/config/entry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const entry = async ({ hooks }) => {
|
|
2
2
|
const entrypoints = hooks.filter(`build.entry`, {
|
|
3
|
-
main: { import: [
|
|
3
|
+
main: { import: [`./index`] },
|
|
4
4
|
});
|
|
5
5
|
return Object.entries(entrypoints).reduce((acc, [key, value]) => {
|
|
6
6
|
value.import = [...new Set(value.import)];
|
package/lib/config/module.js
CHANGED
|
@@ -3,21 +3,115 @@ export const module = async ({ build: { rules }, hooks: { filter }, path, }) =>
|
|
|
3
3
|
rules: getRules({ filter, path, rules }),
|
|
4
4
|
unsafeCache: getUnsafeCache(filter),
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Get all module.rules
|
|
8
|
+
*/
|
|
9
|
+
const getRules = ({ filter, path, rules }) => {
|
|
10
|
+
return [
|
|
11
|
+
...filter(`build.module.rules.before`, [
|
|
12
|
+
{
|
|
13
|
+
include: [path(`@src`)],
|
|
14
|
+
parser: { requireEnsure: false },
|
|
15
|
+
test: filter(`pattern.js`),
|
|
16
|
+
},
|
|
17
|
+
rules.image.toWebpack
|
|
18
|
+
? {
|
|
19
|
+
oneOf: [
|
|
20
|
+
rules[`inline-image`]?.toWebpack?.(),
|
|
21
|
+
rules.image.toWebpack?.(),
|
|
22
|
+
].filter(Boolean),
|
|
23
|
+
test: filter(`pattern.image`),
|
|
24
|
+
}
|
|
25
|
+
: undefined,
|
|
26
|
+
rules.font.toWebpack
|
|
27
|
+
? {
|
|
28
|
+
oneOf: [
|
|
29
|
+
rules[`inline-font`]?.toWebpack?.(),
|
|
30
|
+
rules.font.toWebpack(),
|
|
31
|
+
].filter(Boolean),
|
|
32
|
+
test: filter(`pattern.font`),
|
|
33
|
+
}
|
|
34
|
+
: undefined,
|
|
35
|
+
rules.svg.toWebpack
|
|
36
|
+
? {
|
|
37
|
+
oneOf: [
|
|
38
|
+
rules[`inline-svg`]?.toWebpack?.(),
|
|
39
|
+
rules.svg.toWebpack(),
|
|
40
|
+
].filter(Boolean),
|
|
41
|
+
test: filter(`pattern.svg`),
|
|
42
|
+
}
|
|
43
|
+
: undefined,
|
|
44
|
+
]),
|
|
8
45
|
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
46
|
+
oneOf: [
|
|
47
|
+
...filter(`build.module.rules.oneOf`, [
|
|
48
|
+
...getDefinedRules({ rules }),
|
|
49
|
+
...makeIssuerRuleSet({ filter, path, rules }),
|
|
50
|
+
]),
|
|
51
|
+
].filter(Boolean),
|
|
12
52
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
53
|
+
...filter(`build.module.rules.after`, []),
|
|
54
|
+
].filter(Boolean);
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Get the standard rules defined in the bud config, extensions, etc.
|
|
58
|
+
*/
|
|
59
|
+
const getDefinedRules = ({ rules }) => {
|
|
60
|
+
return [
|
|
61
|
+
...Object.entries(rules)
|
|
62
|
+
.filter(([key, _]) => {
|
|
63
|
+
return !DEFINED.includes(key) && !RESOURCES.includes(key);
|
|
64
|
+
})
|
|
65
|
+
.map(([_, value]) => value),
|
|
66
|
+
...DEFINED.map(key => rules[key]),
|
|
67
|
+
]
|
|
68
|
+
.filter(Boolean)
|
|
69
|
+
.map(rule => (`toWebpack` in rule ? rule.toWebpack() : rule));
|
|
70
|
+
};
|
|
71
|
+
const RESOURCES = [
|
|
72
|
+
`image`,
|
|
73
|
+
`font`,
|
|
74
|
+
`svg`,
|
|
75
|
+
`inline-font`,
|
|
76
|
+
`inline-image`,
|
|
77
|
+
`inline-svg`,
|
|
20
78
|
];
|
|
79
|
+
const DEFINED = [
|
|
80
|
+
`csv`,
|
|
81
|
+
`toml`,
|
|
82
|
+
`yml`,
|
|
83
|
+
`json`,
|
|
84
|
+
`html`,
|
|
85
|
+
`webp`,
|
|
86
|
+
`scss-module`,
|
|
87
|
+
`scss`,
|
|
88
|
+
`css-module`,
|
|
89
|
+
`css`,
|
|
90
|
+
`vue`,
|
|
91
|
+
`js`,
|
|
92
|
+
`ts`,
|
|
93
|
+
];
|
|
94
|
+
/**
|
|
95
|
+
* Get rules for css and css-module imports issued by non-css files.
|
|
96
|
+
*/
|
|
97
|
+
const makeIssuerRuleSet = ({ filter, path, rules }) => {
|
|
98
|
+
const results = [];
|
|
99
|
+
rules[`css-module`]?.toWebpack?.().use &&
|
|
100
|
+
results.push({
|
|
101
|
+
exclude: [path(`@src`)],
|
|
102
|
+
issuer: { not: filter(`pattern.cssModule`) },
|
|
103
|
+
test: filter(`pattern.cssModule`),
|
|
104
|
+
use: rules[`css-module`].toWebpack?.().use,
|
|
105
|
+
});
|
|
106
|
+
rules[`css`]?.toWebpack?.().use &&
|
|
107
|
+
results.push({
|
|
108
|
+
exclude: [path(`@src`)],
|
|
109
|
+
issuer: { not: filter(`pattern.css`) },
|
|
110
|
+
test: filter(`pattern.css`),
|
|
111
|
+
use: rules[`css`].toWebpack?.().use,
|
|
112
|
+
});
|
|
113
|
+
return results;
|
|
114
|
+
};
|
|
21
115
|
const getNoParse = (filter) => filter(`build.module.noParse`, undefined);
|
|
22
116
|
/**
|
|
23
117
|
* By leaving undefined, webpack will strongly cache parsed modules from node_modules
|
package/lib/config/resolve.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import isString from '@roots/bud-support/
|
|
1
|
+
import isString from '@roots/bud-support/isString';
|
|
2
2
|
export const resolve = async (bud) => {
|
|
3
3
|
return await bud.hooks.filterAsync(`build.resolve`, {
|
|
4
4
|
alias: {
|
|
5
|
-
|
|
5
|
+
'@src': bud.path(`@src`),
|
|
6
6
|
...(await bud.hooks.filterAsync(`build.resolve.alias`, {})),
|
|
7
7
|
},
|
|
8
8
|
extensionAlias: await bud.hooks.filterAsync(`build.resolve.extensionAlias`, {
|
|
9
|
-
[`.js`]: [`.ts`, `.tsx`, `.js`],
|
|
9
|
+
[`.js`]: [`.ts`, `.tsx`, `.js`, `.jsx`],
|
|
10
10
|
[`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
|
|
11
11
|
}),
|
|
12
12
|
extensions: Array.from(bud.hooks.filter(`build.resolve.extensions`, new Set([`.js`, `.mjs`, `.css`]))),
|
|
@@ -14,6 +14,7 @@ export const resolve = async (bud) => {
|
|
|
14
14
|
bud.hooks.filter(`location.@src`),
|
|
15
15
|
bud.hooks.filter(`location.@modules`),
|
|
16
16
|
].filter(v => isString(v) && v.length > 0)),
|
|
17
|
+
symlinks: bud.hooks.filter(`build.resolve.symlinks`, undefined),
|
|
17
18
|
/**
|
|
18
19
|
* Leave `undefined` to use webpack default (true in dev, false in production)
|
|
19
20
|
*/
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
export const resolveLoader = async ({ hooks, module, }) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})
|
|
1
|
+
export const resolveLoader = async ({ hooks, module, }) => {
|
|
2
|
+
const result = hooks.filter(`build.resolveLoader`, {
|
|
3
|
+
alias: hooks.filter(`build.resolveLoader.alias`, {
|
|
4
|
+
'css-loader': await module.resolve(`@roots/bud-support/css-loader`),
|
|
5
|
+
'file-loader': await module.resolve(`@roots/bud-support/file-loader`),
|
|
6
|
+
'html-loader': await module.resolve(`@roots/bud-support/html-loader`),
|
|
7
|
+
'style-loader': await module.resolve(`@roots/bud-support/style-loader`),
|
|
8
|
+
}),
|
|
9
|
+
});
|
|
10
|
+
const modules = hooks.filter(`build.resolveLoader.modules`, undefined);
|
|
11
|
+
if (modules)
|
|
12
|
+
result.modules = modules;
|
|
13
|
+
return result;
|
|
14
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -41,18 +41,22 @@ declare module '@roots/bud-framework' {
|
|
|
41
41
|
}
|
|
42
42
|
interface Rules {
|
|
43
43
|
[`css-module`]: Rule;
|
|
44
|
+
[`inline-font`]: Rule;
|
|
45
|
+
[`inline-image`]: Rule;
|
|
46
|
+
[`inline-svg`]: Rule;
|
|
44
47
|
css: Rule;
|
|
45
48
|
csv: Rule;
|
|
46
49
|
font: Rule;
|
|
47
50
|
html: Rule;
|
|
48
51
|
image: Rule;
|
|
49
|
-
inlineFont: Rule;
|
|
50
|
-
inlineImage: Rule;
|
|
51
|
-
inlineSvg: Rule;
|
|
52
52
|
js: Rule;
|
|
53
53
|
json: Rule;
|
|
54
|
+
sass: Rule;
|
|
54
55
|
svg: Rule;
|
|
55
56
|
toml: Rule;
|
|
57
|
+
ts: Rule;
|
|
58
|
+
vue: Rule;
|
|
59
|
+
webp: Rule;
|
|
56
60
|
yml: Rule;
|
|
57
61
|
}
|
|
58
62
|
}
|
package/lib/item/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { basename } from 'node:path';
|
|
|
3
3
|
import Registrable from '@roots/bud-build/helpers/registrable';
|
|
4
4
|
import Loader from '@roots/bud-build/loader';
|
|
5
5
|
import { bind } from '@roots/bud-support/decorators/bind';
|
|
6
|
-
import isString from '@roots/bud-support/
|
|
6
|
+
import isString from '@roots/bud-support/isString';
|
|
7
7
|
import logger from '@roots/bud-support/logger';
|
|
8
8
|
/**
|
|
9
9
|
* Item class
|
package/lib/items/index.js
CHANGED
package/lib/registry/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as items from '@roots/bud-build/items';
|
|
2
2
|
import * as loaders from '@roots/bud-build/loaders';
|
|
3
3
|
import * as rules from '@roots/bud-build/rules';
|
|
4
|
-
import kebabCase from '@roots/bud-support/
|
|
4
|
+
import kebabCase from '@roots/bud-support/kebabCase';
|
|
5
5
|
/**
|
|
6
6
|
* Register built-in {@link loaders}, {@link items} and {@link rules}
|
|
7
7
|
*/
|
package/lib/rule/index.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ declare class Rule extends Registrable implements Interface {
|
|
|
18
18
|
* RuleSetRule include
|
|
19
19
|
*/
|
|
20
20
|
include?: Options[`include`];
|
|
21
|
+
/**
|
|
22
|
+
* RuleSetRule issuer
|
|
23
|
+
*/
|
|
24
|
+
issuer?: Options[`issuer`];
|
|
21
25
|
/**
|
|
22
26
|
* RuleSetRule parser
|
|
23
27
|
*/
|
|
@@ -60,6 +64,10 @@ declare class Rule extends Registrable implements Interface {
|
|
|
60
64
|
* Get `include` value
|
|
61
65
|
*/
|
|
62
66
|
getInclude(): Array<RegExp | string>;
|
|
67
|
+
/**
|
|
68
|
+
* Get `issuer` value
|
|
69
|
+
*/
|
|
70
|
+
getIssuer(): Output['issuer'];
|
|
63
71
|
/**
|
|
64
72
|
* Get `parser` value
|
|
65
73
|
*/
|
|
@@ -96,6 +104,10 @@ declare class Rule extends Registrable implements Interface {
|
|
|
96
104
|
* Set `include` value
|
|
97
105
|
*/
|
|
98
106
|
setInclude(includes: Options['include']): this;
|
|
107
|
+
/**
|
|
108
|
+
* Set `issuer` value
|
|
109
|
+
*/
|
|
110
|
+
setIssuer(issuer: Options['issuer']): this;
|
|
99
111
|
/**
|
|
100
112
|
* Set `parser` value
|
|
101
113
|
*/
|
package/lib/rule/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import Registrable from '@roots/bud-build/helpers/registrable';
|
|
3
3
|
import { bind } from '@roots/bud-support/decorators/bind';
|
|
4
|
-
import isFunction from '@roots/bud-support/
|
|
5
|
-
import isString from '@roots/bud-support/
|
|
4
|
+
import isFunction from '@roots/bud-support/isFunction';
|
|
5
|
+
import isString from '@roots/bud-support/isString';
|
|
6
6
|
import logger from '@roots/bud-support/logger';
|
|
7
7
|
/**
|
|
8
8
|
* RuleSetRule
|
|
@@ -20,6 +20,10 @@ class Rule extends Registrable {
|
|
|
20
20
|
* RuleSetRule include
|
|
21
21
|
*/
|
|
22
22
|
include;
|
|
23
|
+
/**
|
|
24
|
+
* RuleSetRule issuer
|
|
25
|
+
*/
|
|
26
|
+
issuer;
|
|
23
27
|
/**
|
|
24
28
|
* RuleSetRule parser
|
|
25
29
|
*/
|
|
@@ -79,6 +83,12 @@ class Rule extends Registrable {
|
|
|
79
83
|
getInclude() {
|
|
80
84
|
return this.include?.map(this.unwrap);
|
|
81
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Get `issuer` value
|
|
88
|
+
*/
|
|
89
|
+
getIssuer() {
|
|
90
|
+
return this.issuer;
|
|
91
|
+
}
|
|
82
92
|
/**
|
|
83
93
|
* Get `parser` value
|
|
84
94
|
*/
|
|
@@ -138,6 +148,13 @@ class Rule extends Registrable {
|
|
|
138
148
|
this.include = isFunction(includes) ? includes(this.include) : includes;
|
|
139
149
|
return this;
|
|
140
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Set `issuer` value
|
|
153
|
+
*/
|
|
154
|
+
setIssuer(issuer) {
|
|
155
|
+
this.issuer = issuer;
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
141
158
|
/**
|
|
142
159
|
* Set `parser` value
|
|
143
160
|
*/
|
|
@@ -190,6 +207,7 @@ class Rule extends Registrable {
|
|
|
190
207
|
exclude: this.getExclude(),
|
|
191
208
|
generator: this.getGenerator(),
|
|
192
209
|
include: this.getInclude(),
|
|
210
|
+
issuer: this.getIssuer(),
|
|
193
211
|
parser: this.getParser(),
|
|
194
212
|
resolve: this.getResolve(),
|
|
195
213
|
resourceQuery: this.getResourceQuery(),
|
|
@@ -220,6 +238,9 @@ __decorate([
|
|
|
220
238
|
__decorate([
|
|
221
239
|
bind
|
|
222
240
|
], Rule.prototype, "getInclude", null);
|
|
241
|
+
__decorate([
|
|
242
|
+
bind
|
|
243
|
+
], Rule.prototype, "getIssuer", null);
|
|
223
244
|
__decorate([
|
|
224
245
|
bind
|
|
225
246
|
], Rule.prototype, "getParser", null);
|
|
@@ -244,6 +265,9 @@ __decorate([
|
|
|
244
265
|
__decorate([
|
|
245
266
|
bind
|
|
246
267
|
], Rule.prototype, "setInclude", null);
|
|
268
|
+
__decorate([
|
|
269
|
+
bind
|
|
270
|
+
], Rule.prototype, "setIssuer", null);
|
|
247
271
|
__decorate([
|
|
248
272
|
bind
|
|
249
273
|
], Rule.prototype, "setParser", null);
|
package/lib/service/index.js
CHANGED
|
@@ -5,8 +5,8 @@ import { register } from '@roots/bud-build/registry';
|
|
|
5
5
|
import Rule, {} from '@roots/bud-build/rule';
|
|
6
6
|
import { Service } from '@roots/bud-framework/service';
|
|
7
7
|
import { bind } from '@roots/bud-support/decorators/bind';
|
|
8
|
-
import isFunction from '@roots/bud-support/
|
|
9
|
-
import isUndefined from '@roots/bud-support/
|
|
8
|
+
import isFunction from '@roots/bud-support/isFunction';
|
|
9
|
+
import isUndefined from '@roots/bud-support/isUndefined';
|
|
10
10
|
/**
|
|
11
11
|
* {@link BudBuild}
|
|
12
12
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roots/bud-build",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.19.1",
|
|
4
4
|
"description": "bud.js core module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16"
|
|
@@ -169,14 +169,14 @@
|
|
|
169
169
|
"types": "./lib/index.d.ts",
|
|
170
170
|
"module": "./lib/index.js",
|
|
171
171
|
"devDependencies": {
|
|
172
|
-
"@roots/bud-api": "6.
|
|
173
|
-
"@roots/bud-hooks": "6.
|
|
172
|
+
"@roots/bud-api": "6.19.1",
|
|
173
|
+
"@roots/bud-hooks": "6.19.1",
|
|
174
174
|
"@skypack/package-check": "0.2.2",
|
|
175
|
-
"@types/node": "20.
|
|
175
|
+
"@types/node": "20.10.4"
|
|
176
176
|
},
|
|
177
177
|
"dependencies": {
|
|
178
|
-
"@roots/bud-framework": "6.
|
|
179
|
-
"@roots/bud-support": "6.
|
|
178
|
+
"@roots/bud-framework": "6.19.1",
|
|
179
|
+
"@roots/bud-support": "6.19.1",
|
|
180
180
|
"tslib": "2.6.2"
|
|
181
181
|
},
|
|
182
182
|
"volta": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
3
|
import {ConfigError} from '@roots/bud-support/errors'
|
|
4
|
-
import isUndefined from '@roots/bud-support/
|
|
4
|
+
import isUndefined from '@roots/bud-support/isUndefined'
|
|
5
5
|
|
|
6
6
|
export const dependencies: Factory<`dependencies`> = async ({
|
|
7
7
|
hooks,
|
package/src/config/entry.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type {Factory} from '@roots/bud-build/config'
|
|
|
2
2
|
|
|
3
3
|
export const entry: Factory<`entry`> = async ({hooks}) => {
|
|
4
4
|
const entrypoints = hooks.filter(`build.entry`, {
|
|
5
|
-
main: {import: [
|
|
5
|
+
main: {import: [`./index`]},
|
|
6
6
|
})
|
|
7
7
|
|
|
8
8
|
return Object.entries(entrypoints).reduce((acc, [key, value]) => {
|
package/src/config/module.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {Factory} from '@roots/bud-build/config'
|
|
2
|
-
import type {Bud} from '@roots/bud-framework'
|
|
2
|
+
import type {Bud, RuleSetRule} from '@roots/bud-framework'
|
|
3
3
|
|
|
4
4
|
interface Props {
|
|
5
5
|
filter: Bud[`hooks`][`filter`]
|
|
@@ -18,25 +18,125 @@ export const module: Factory<`module`> = async ({
|
|
|
18
18
|
unsafeCache: getUnsafeCache(filter),
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Get all module.rules
|
|
23
|
+
*/
|
|
24
|
+
const getRules = ({filter, path, rules}: Props): Array<RuleSetRule> => {
|
|
25
|
+
return [
|
|
26
|
+
...filter(`build.module.rules.before`, [
|
|
27
|
+
{
|
|
28
|
+
include: [path(`@src`)],
|
|
29
|
+
parser: {requireEnsure: false},
|
|
30
|
+
test: filter(`pattern.js`),
|
|
31
|
+
},
|
|
32
|
+
rules.image.toWebpack
|
|
33
|
+
? {
|
|
34
|
+
oneOf: [
|
|
35
|
+
rules[`inline-image`]?.toWebpack?.(),
|
|
36
|
+
rules.image.toWebpack?.(),
|
|
37
|
+
].filter(Boolean),
|
|
38
|
+
test: filter(`pattern.image`),
|
|
39
|
+
}
|
|
40
|
+
: undefined,
|
|
41
|
+
|
|
42
|
+
rules.font.toWebpack
|
|
43
|
+
? {
|
|
44
|
+
oneOf: [
|
|
45
|
+
rules[`inline-font`]?.toWebpack?.(),
|
|
46
|
+
rules.font.toWebpack(),
|
|
47
|
+
].filter(Boolean),
|
|
48
|
+
test: filter(`pattern.font`),
|
|
49
|
+
}
|
|
50
|
+
: undefined,
|
|
51
|
+
|
|
52
|
+
rules.svg.toWebpack
|
|
53
|
+
? {
|
|
54
|
+
oneOf: [
|
|
55
|
+
rules[`inline-svg`]?.toWebpack?.(),
|
|
56
|
+
rules.svg.toWebpack(),
|
|
57
|
+
].filter(Boolean),
|
|
58
|
+
test: filter(`pattern.svg`),
|
|
59
|
+
}
|
|
60
|
+
: undefined,
|
|
61
|
+
]),
|
|
23
62
|
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
63
|
+
oneOf: [
|
|
64
|
+
...filter(`build.module.rules.oneOf`, [
|
|
65
|
+
...getDefinedRules({rules}),
|
|
66
|
+
...makeIssuerRuleSet({filter, path, rules}),
|
|
67
|
+
]),
|
|
68
|
+
].filter(Boolean),
|
|
27
69
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
70
|
+
...filter(`build.module.rules.after`, []),
|
|
71
|
+
].filter(Boolean)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get the standard rules defined in the bud config, extensions, etc.
|
|
76
|
+
*/
|
|
77
|
+
const getDefinedRules = ({rules}: Partial<Props>) => {
|
|
78
|
+
return [
|
|
79
|
+
...Object.entries(rules)
|
|
80
|
+
.filter(([key, _]) => {
|
|
81
|
+
return !DEFINED.includes(key) && !RESOURCES.includes(key)
|
|
82
|
+
})
|
|
83
|
+
.map(([_, value]) => value),
|
|
84
|
+
...DEFINED.map(key => rules[key]),
|
|
85
|
+
]
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.map(rule => (`toWebpack` in rule ? rule.toWebpack() : rule))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const RESOURCES = [
|
|
91
|
+
`image`,
|
|
92
|
+
`font`,
|
|
93
|
+
`svg`,
|
|
94
|
+
`inline-font`,
|
|
95
|
+
`inline-image`,
|
|
96
|
+
`inline-svg`,
|
|
38
97
|
]
|
|
39
98
|
|
|
99
|
+
const DEFINED = [
|
|
100
|
+
`csv`,
|
|
101
|
+
`toml`,
|
|
102
|
+
`yml`,
|
|
103
|
+
`json`,
|
|
104
|
+
`html`,
|
|
105
|
+
`webp`,
|
|
106
|
+
`scss-module`,
|
|
107
|
+
`scss`,
|
|
108
|
+
`css-module`,
|
|
109
|
+
`css`,
|
|
110
|
+
`vue`,
|
|
111
|
+
`js`,
|
|
112
|
+
`ts`,
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Get rules for css and css-module imports issued by non-css files.
|
|
117
|
+
*/
|
|
118
|
+
const makeIssuerRuleSet = ({filter, path, rules}: Props) => {
|
|
119
|
+
const results = []
|
|
120
|
+
|
|
121
|
+
rules[`css-module`]?.toWebpack?.().use &&
|
|
122
|
+
results.push({
|
|
123
|
+
exclude: [path(`@src`)],
|
|
124
|
+
issuer: {not: filter(`pattern.cssModule`)},
|
|
125
|
+
test: filter(`pattern.cssModule`),
|
|
126
|
+
use: rules[`css-module`].toWebpack?.().use,
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
rules[`css`]?.toWebpack?.().use &&
|
|
130
|
+
results.push({
|
|
131
|
+
exclude: [path(`@src`)],
|
|
132
|
+
issuer: {not: filter(`pattern.css`)},
|
|
133
|
+
test: filter(`pattern.css`),
|
|
134
|
+
use: rules[`css`].toWebpack?.().use,
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
return results
|
|
138
|
+
}
|
|
139
|
+
|
|
40
140
|
const getNoParse = (filter: Props[`filter`]) =>
|
|
41
141
|
filter(`build.module.noParse`, undefined)
|
|
42
142
|
|
package/src/config/resolve.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import type {Factory} from '@roots/bud-build/config'
|
|
2
2
|
|
|
3
|
-
import isString from '@roots/bud-support/
|
|
3
|
+
import isString from '@roots/bud-support/isString'
|
|
4
4
|
|
|
5
5
|
export const resolve: Factory<`resolve`> = async bud => {
|
|
6
6
|
return await bud.hooks.filterAsync(`build.resolve`, {
|
|
7
7
|
alias: {
|
|
8
|
-
|
|
8
|
+
'@src': bud.path(`@src`),
|
|
9
9
|
...(await bud.hooks.filterAsync(`build.resolve.alias`, {})),
|
|
10
10
|
},
|
|
11
11
|
|
|
12
12
|
extensionAlias: await bud.hooks.filterAsync(
|
|
13
13
|
`build.resolve.extensionAlias`,
|
|
14
14
|
{
|
|
15
|
-
[`.js`]: [`.ts`, `.tsx`, `.js`],
|
|
15
|
+
[`.js`]: [`.ts`, `.tsx`, `.js`, `.jsx`],
|
|
16
16
|
[`.mjs`]: [`.mts`, `.mtx`, `.mjs`],
|
|
17
17
|
},
|
|
18
18
|
),
|
|
@@ -32,6 +32,8 @@ export const resolve: Factory<`resolve`> = async bud => {
|
|
|
32
32
|
].filter(v => isString(v) && v.length > 0),
|
|
33
33
|
),
|
|
34
34
|
|
|
35
|
+
symlinks: bud.hooks.filter(`build.resolve.symlinks`, undefined),
|
|
36
|
+
|
|
35
37
|
/**
|
|
36
38
|
* Leave `undefined` to use webpack default (true in dev, false in production)
|
|
37
39
|
*/
|
|
@@ -3,8 +3,8 @@ import type {Factory} from '@roots/bud-build/config'
|
|
|
3
3
|
export const resolveLoader: Factory<`resolveLoader`> = async ({
|
|
4
4
|
hooks,
|
|
5
5
|
module,
|
|
6
|
-
}) =>
|
|
7
|
-
hooks.filter(`build.resolveLoader`, {
|
|
6
|
+
}) => {
|
|
7
|
+
const result = hooks.filter(`build.resolveLoader`, {
|
|
8
8
|
alias: hooks.filter(`build.resolveLoader.alias`, {
|
|
9
9
|
'css-loader': await module.resolve(`@roots/bud-support/css-loader`),
|
|
10
10
|
'file-loader': await module.resolve(
|
|
@@ -18,3 +18,9 @@ export const resolveLoader: Factory<`resolveLoader`> = async ({
|
|
|
18
18
|
),
|
|
19
19
|
}),
|
|
20
20
|
})
|
|
21
|
+
|
|
22
|
+
const modules = hooks.filter(`build.resolveLoader.modules`, undefined)
|
|
23
|
+
if (modules) result.modules = modules
|
|
24
|
+
|
|
25
|
+
return result
|
|
26
|
+
}
|
|
@@ -2,7 +2,7 @@ import type {Bud} from '@roots/bud-framework'
|
|
|
2
2
|
import type {Base as BuildBase} from '@roots/bud-framework/services/build'
|
|
3
3
|
|
|
4
4
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
5
|
-
import isFunction from '@roots/bud-support/
|
|
5
|
+
import isFunction from '@roots/bud-support/isFunction'
|
|
6
6
|
|
|
7
7
|
class Registrable implements BuildBase {
|
|
8
8
|
/**
|
package/src/index.ts
CHANGED
|
@@ -49,18 +49,22 @@ declare module '@roots/bud-framework' {
|
|
|
49
49
|
|
|
50
50
|
interface Rules {
|
|
51
51
|
[`css-module`]: Rule
|
|
52
|
+
[`inline-font`]: Rule
|
|
53
|
+
[`inline-image`]: Rule
|
|
54
|
+
[`inline-svg`]: Rule
|
|
52
55
|
css: Rule
|
|
53
56
|
csv: Rule
|
|
54
57
|
font: Rule
|
|
55
58
|
html: Rule
|
|
56
59
|
image: Rule
|
|
57
|
-
inlineFont: Rule
|
|
58
|
-
inlineImage: Rule
|
|
59
|
-
inlineSvg: Rule
|
|
60
60
|
js: Rule
|
|
61
61
|
json: Rule
|
|
62
|
+
sass: Rule
|
|
62
63
|
svg: Rule
|
|
63
64
|
toml: Rule
|
|
65
|
+
ts: Rule
|
|
66
|
+
vue: Rule
|
|
67
|
+
webp: Rule
|
|
64
68
|
yml: Rule
|
|
65
69
|
}
|
|
66
70
|
}
|
package/src/item/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {basename} from 'node:path'
|
|
|
6
6
|
import Registrable from '@roots/bud-build/helpers/registrable'
|
|
7
7
|
import Loader from '@roots/bud-build/loader'
|
|
8
8
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
9
|
-
import isString from '@roots/bud-support/
|
|
9
|
+
import isString from '@roots/bud-support/isString'
|
|
10
10
|
import logger from '@roots/bud-support/logger'
|
|
11
11
|
|
|
12
12
|
export type ConstructorOptions = Build.Item.ConstructorOptions
|
package/src/items/index.ts
CHANGED
package/src/registry/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {Bud} from '@roots/bud-framework'
|
|
|
4
4
|
import * as items from '@roots/bud-build/items'
|
|
5
5
|
import * as loaders from '@roots/bud-build/loaders'
|
|
6
6
|
import * as rules from '@roots/bud-build/rules'
|
|
7
|
-
import kebabCase from '@roots/bud-support/
|
|
7
|
+
import kebabCase from '@roots/bud-support/kebabCase'
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
10
|
filter: Bud[`hooks`][`filter`]
|
package/src/rule/index.ts
CHANGED
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
|
|
10
10
|
import Registrable from '@roots/bud-build/helpers/registrable'
|
|
11
11
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
12
|
-
import isFunction from '@roots/bud-support/
|
|
13
|
-
import isString from '@roots/bud-support/
|
|
12
|
+
import isFunction from '@roots/bud-support/isFunction'
|
|
13
|
+
import isString from '@roots/bud-support/isString'
|
|
14
14
|
import logger from '@roots/bud-support/logger'
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -32,6 +32,11 @@ class Rule extends Registrable implements Interface {
|
|
|
32
32
|
*/
|
|
33
33
|
public include?: Options[`include`]
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* RuleSetRule issuer
|
|
37
|
+
*/
|
|
38
|
+
public issuer?: Options[`issuer`]
|
|
39
|
+
|
|
35
40
|
/**
|
|
36
41
|
* RuleSetRule parser
|
|
37
42
|
*/
|
|
@@ -105,6 +110,14 @@ class Rule extends Registrable implements Interface {
|
|
|
105
110
|
return this.include?.map(this.unwrap)
|
|
106
111
|
}
|
|
107
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Get `issuer` value
|
|
115
|
+
*/
|
|
116
|
+
@bind
|
|
117
|
+
public getIssuer(): Output['issuer'] {
|
|
118
|
+
return this.issuer
|
|
119
|
+
}
|
|
120
|
+
|
|
108
121
|
/**
|
|
109
122
|
* Get `parser` value
|
|
110
123
|
*/
|
|
@@ -185,6 +198,15 @@ class Rule extends Registrable implements Interface {
|
|
|
185
198
|
return this
|
|
186
199
|
}
|
|
187
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Set `issuer` value
|
|
203
|
+
*/
|
|
204
|
+
@bind
|
|
205
|
+
public setIssuer(issuer: Options['issuer']): this {
|
|
206
|
+
this.issuer = issuer
|
|
207
|
+
return this
|
|
208
|
+
}
|
|
209
|
+
|
|
188
210
|
/**
|
|
189
211
|
* Set `parser` value
|
|
190
212
|
*/
|
|
@@ -253,6 +275,7 @@ class Rule extends Registrable implements Interface {
|
|
|
253
275
|
exclude: this.getExclude(),
|
|
254
276
|
generator: this.getGenerator(),
|
|
255
277
|
include: this.getInclude(),
|
|
278
|
+
issuer: this.getIssuer(),
|
|
256
279
|
parser: this.getParser(),
|
|
257
280
|
resolve: this.getResolve(),
|
|
258
281
|
resourceQuery: this.getResourceQuery(),
|
package/src/service/index.ts
CHANGED
|
@@ -8,8 +8,8 @@ import {register} from '@roots/bud-build/registry'
|
|
|
8
8
|
import Rule, {type Options as RuleOptions} from '@roots/bud-build/rule'
|
|
9
9
|
import {Service} from '@roots/bud-framework/service'
|
|
10
10
|
import {bind} from '@roots/bud-support/decorators/bind'
|
|
11
|
-
import isFunction from '@roots/bud-support/
|
|
12
|
-
import isUndefined from '@roots/bud-support/
|
|
11
|
+
import isFunction from '@roots/bud-support/isFunction'
|
|
12
|
+
import isUndefined from '@roots/bud-support/isUndefined'
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* {@link BudBuild}
|