@roots/bud-build 5.0.0 → 5.3.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.js +250 -252
- package/lib/cjs/Build/index.js +120 -77
- package/lib/cjs/Build/items.js +17 -21
- package/lib/cjs/Build/loaders.js +5 -4
- package/lib/cjs/Build/rules.js +132 -94
- package/lib/cjs/Item/index.js +16 -9
- package/lib/cjs/Item/item.dependencies.js +0 -1
- package/lib/cjs/Item/item.interface.js +0 -1
- package/lib/cjs/Loader/index.js +27 -4
- package/lib/cjs/Rule/index.js +178 -81
- package/lib/cjs/index.js +22 -5
- package/lib/cjs/shared/Base.js +0 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -32
- package/types/Build/config.d.ts.map +1 -1
- package/types/Build/index.d.ts +19 -4
- package/types/Build/index.d.ts.map +1 -1
- package/types/Build/items.d.ts +3 -3
- package/types/Build/items.d.ts.map +1 -1
- package/types/Build/loaders.d.ts.map +1 -1
- package/types/Build/rules.d.ts +38 -21
- package/types/Build/rules.d.ts.map +1 -1
- package/types/Item/index.d.ts +1 -1
- package/types/Item/index.d.ts.map +1 -1
- package/types/Rule/index.d.ts +122 -24
- package/types/Rule/index.d.ts.map +1 -1
- package/types/shared/Base.d.ts.map +1 -1
- package/lib/cjs/Build/config.js.map +0 -1
- package/lib/cjs/Build/index.js.map +0 -1
- package/lib/cjs/Build/items.js.map +0 -1
- package/lib/cjs/Build/loaders.js.map +0 -1
- package/lib/cjs/Build/rules.js.map +0 -1
- package/lib/cjs/Item/index.js.map +0 -1
- package/lib/cjs/Item/item.dependencies.js.map +0 -1
- package/lib/cjs/Item/item.interface.js.map +0 -1
- package/lib/cjs/Loader/index.js.map +0 -1
- package/lib/cjs/Rule/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/shared/Base.js.map +0 -1
- package/lib/esm/Build/config.js +0 -263
- package/lib/esm/Build/config.js.map +0 -1
- package/lib/esm/Build/index.js +0 -133
- package/lib/esm/Build/index.js.map +0 -1
- package/lib/esm/Build/items.js +0 -119
- package/lib/esm/Build/items.js.map +0 -1
- package/lib/esm/Build/loaders.js +0 -55
- package/lib/esm/Build/loaders.js.map +0 -1
- package/lib/esm/Build/rules.js +0 -129
- package/lib/esm/Build/rules.js.map +0 -1
- package/lib/esm/Item/index.js +0 -80
- package/lib/esm/Item/index.js.map +0 -1
- package/lib/esm/Item/item.dependencies.js +0 -4
- package/lib/esm/Item/item.dependencies.js.map +0 -1
- package/lib/esm/Item/item.interface.js +0 -2
- package/lib/esm/Item/item.interface.js.map +0 -1
- package/lib/esm/Loader/index.js +0 -49
- package/lib/esm/Loader/index.js.map +0 -1
- package/lib/esm/Rule/index.js +0 -155
- package/lib/esm/Rule/index.js.map +0 -1
- package/lib/esm/index.js +0 -26
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/shared/Base.js +0 -8
- package/lib/esm/shared/Base.js.map +0 -1
- package/lib/tsconfig-esm.tsbuildinfo +0 -1
package/lib/cjs/Build/index.js
CHANGED
|
@@ -1,13 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
15
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
16
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
17
|
+
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;
|
|
18
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
19
|
+
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
2
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
31
|
exports.Build = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
32
|
const bud_framework_1 = require("@roots/bud-framework");
|
|
6
33
|
const bud_support_1 = require("@roots/bud-support");
|
|
34
|
+
const Rule_1 = require("../Rule");
|
|
7
35
|
const config_1 = require("./config");
|
|
8
|
-
const items_1 =
|
|
9
|
-
const loaders_1 =
|
|
10
|
-
const rules =
|
|
36
|
+
const items_1 = __importDefault(require("./items"));
|
|
37
|
+
const loaders_1 = __importDefault(require("./loaders"));
|
|
38
|
+
const rules = __importStar(require("./rules"));
|
|
11
39
|
const { isNull, isUndefined } = bud_support_1.lodash;
|
|
12
40
|
const { ensureFile, writeFile } = bud_support_1.fs;
|
|
13
41
|
/**
|
|
@@ -22,10 +50,8 @@ class Build extends bud_framework_1.Service {
|
|
|
22
50
|
* @public
|
|
23
51
|
* @decorator `@bind`
|
|
24
52
|
*/
|
|
25
|
-
registered() {
|
|
26
|
-
|
|
27
|
-
this.app.hooks.on('event.build.make.after', this.writeFinalConfig);
|
|
28
|
-
});
|
|
53
|
+
async registered() {
|
|
54
|
+
this.app.hooks.on('event.build.make.after', this.writeFinalConfig);
|
|
29
55
|
}
|
|
30
56
|
/**
|
|
31
57
|
* Make webpack configuration
|
|
@@ -33,31 +59,28 @@ class Build extends bud_framework_1.Service {
|
|
|
33
59
|
* @public
|
|
34
60
|
* @decorator `@bind`
|
|
35
61
|
*/
|
|
36
|
-
make() {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
62
|
+
async make() {
|
|
63
|
+
await this.app.hooks.filterAsync('event.build.make.before', this.app);
|
|
64
|
+
const build = await this.app.hooks.filterAsync('build');
|
|
65
|
+
if (!build) {
|
|
66
|
+
throw new Error('Configuration could not be processed');
|
|
67
|
+
}
|
|
68
|
+
this.config = await this.app.hooks.filterAsync('event.build.override', Object.entries(build).reduce((all, [key, value]) => {
|
|
69
|
+
if (isUndefined(value) || isNull(value)) {
|
|
70
|
+
this.log(`warn`, {
|
|
71
|
+
message: `build.make: excluding ${key}`,
|
|
72
|
+
suffix: `value is undefined`,
|
|
73
|
+
});
|
|
74
|
+
return all;
|
|
42
75
|
}
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
this.app.dump(value, {
|
|
53
|
-
prefix: `${bud_support_1.chalk.bgBlue(this.app.name)} config.${key}`,
|
|
54
|
-
maxDepth: 2,
|
|
55
|
-
});
|
|
56
|
-
return Object.assign(Object.assign({}, all), { [key]: value });
|
|
57
|
-
}, {}));
|
|
58
|
-
yield this.app.hooks.filterAsync('event.build.make.after', () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { return null; }));
|
|
59
|
-
return this.config;
|
|
60
|
-
});
|
|
76
|
+
this.app.dump(value, {
|
|
77
|
+
prefix: `${bud_support_1.chalk.bgBlue(this.app.name)} config.${key}`,
|
|
78
|
+
maxDepth: 2,
|
|
79
|
+
});
|
|
80
|
+
return { ...all, [key]: value };
|
|
81
|
+
}, {}));
|
|
82
|
+
await this.app.hooks.filterAsync('event.build.make.after', async () => null);
|
|
83
|
+
return this.config;
|
|
61
84
|
}
|
|
62
85
|
/**
|
|
63
86
|
* Service register event
|
|
@@ -65,73 +88,93 @@ class Build extends bud_framework_1.Service {
|
|
|
65
88
|
* @public
|
|
66
89
|
* @decorator `@bind`
|
|
67
90
|
*/
|
|
68
|
-
register() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
91
|
+
async register() {
|
|
92
|
+
const reducer = (a, [k, v]) => ({
|
|
93
|
+
...a,
|
|
94
|
+
[k]: v(this.app),
|
|
95
|
+
});
|
|
96
|
+
Object.assign(this, {
|
|
97
|
+
loaders: this.app
|
|
98
|
+
.container(loaders_1.default)
|
|
99
|
+
.getEntries()
|
|
100
|
+
.reduce(reducer, this.loaders),
|
|
101
|
+
rules: this.app
|
|
102
|
+
.container(rules)
|
|
103
|
+
.getEntries()
|
|
104
|
+
.reduce(reducer, this.rules),
|
|
105
|
+
items: this.app
|
|
106
|
+
.container(items_1.default)
|
|
107
|
+
.getEntries()
|
|
108
|
+
.reduce(reducer, this.items),
|
|
86
109
|
});
|
|
110
|
+
await (0, config_1.config)(this.app);
|
|
87
111
|
}
|
|
88
112
|
/**
|
|
89
|
-
*
|
|
113
|
+
* Set a rule
|
|
114
|
+
*
|
|
115
|
+
* @param name - rule key
|
|
116
|
+
* @param constructorProperties - rule constructor properties
|
|
117
|
+
* @returns the rule
|
|
90
118
|
*
|
|
91
119
|
* @public
|
|
92
120
|
* @decorator `@bind`
|
|
93
121
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const filePath = this.app.path('storage', this.config.name, 'webpack.config.js');
|
|
98
|
-
this.log('log', {
|
|
99
|
-
message: `writing webpack dump to disk`,
|
|
100
|
-
suffix: filePath,
|
|
101
|
-
});
|
|
102
|
-
yield ensureFile(filePath);
|
|
103
|
-
yield writeFile(filePath, `module.exports = (${(0, bud_support_1.prettyFormat)(this.config)})`);
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
this.log('error', `failed to write webpack.config.json`);
|
|
107
|
-
this.log(`error`, error);
|
|
108
|
-
}
|
|
122
|
+
setRule(name, constructorProperties) {
|
|
123
|
+
Object.assign(this.rules, {
|
|
124
|
+
[name]: this.makeRule(constructorProperties),
|
|
109
125
|
});
|
|
126
|
+
return this.rules[name];
|
|
110
127
|
}
|
|
111
128
|
/**
|
|
112
|
-
*
|
|
129
|
+
* Make a rule
|
|
130
|
+
*
|
|
131
|
+
* @param constructorProperties - rule constructor properties
|
|
132
|
+
* @returns the rule
|
|
113
133
|
*
|
|
114
134
|
* @public
|
|
115
135
|
* @decorator `@bind`
|
|
116
136
|
*/
|
|
117
|
-
|
|
118
|
-
return
|
|
137
|
+
makeRule(constructorProperties) {
|
|
138
|
+
return new Rule_1.Rule(this.app, constructorProperties);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Write final configuration to storage directory
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
144
|
+
* @decorator `@bind`
|
|
145
|
+
*/
|
|
146
|
+
async writeFinalConfig() {
|
|
147
|
+
try {
|
|
148
|
+
const filePath = this.app.path('storage', this.config.name, 'webpack.config.js');
|
|
149
|
+
this.log('log', {
|
|
150
|
+
message: `writing webpack dump to disk`,
|
|
151
|
+
suffix: filePath,
|
|
152
|
+
});
|
|
153
|
+
await ensureFile(filePath);
|
|
154
|
+
await writeFile(filePath, `module.exports = (${(0, bud_support_1.prettyFormat)(this.config)})`);
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
this.log('error', `failed to write webpack.config.json`);
|
|
158
|
+
this.log(`error`, error);
|
|
159
|
+
}
|
|
119
160
|
}
|
|
120
161
|
}
|
|
121
|
-
|
|
162
|
+
__decorate([
|
|
122
163
|
bud_support_1.bind
|
|
123
164
|
], Build.prototype, "registered", null);
|
|
124
|
-
|
|
165
|
+
__decorate([
|
|
125
166
|
bud_support_1.bind
|
|
126
167
|
], Build.prototype, "make", null);
|
|
127
|
-
|
|
168
|
+
__decorate([
|
|
128
169
|
bud_support_1.bind
|
|
129
170
|
], Build.prototype, "register", null);
|
|
130
|
-
|
|
171
|
+
__decorate([
|
|
131
172
|
bud_support_1.bind
|
|
132
|
-
], Build.prototype, "
|
|
133
|
-
|
|
173
|
+
], Build.prototype, "setRule", null);
|
|
174
|
+
__decorate([
|
|
134
175
|
bud_support_1.bind
|
|
135
|
-
], Build.prototype, "
|
|
176
|
+
], Build.prototype, "makeRule", null);
|
|
177
|
+
__decorate([
|
|
178
|
+
bud_support_1.bind
|
|
179
|
+
], Build.prototype, "writeFinalConfig", null);
|
|
136
180
|
exports.Build = Build;
|
|
137
|
-
//# sourceMappingURL=index.js.map
|
package/lib/cjs/Build/items.js
CHANGED
|
@@ -8,16 +8,15 @@ const Item_1 = require("../Item");
|
|
|
8
8
|
*/
|
|
9
9
|
exports.default = {
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* .css handler factory
|
|
12
12
|
*
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
loader: ({ build }) => build.loaders.
|
|
17
|
-
options:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
: app.store.get('fileFormat')}.[ext]`,
|
|
15
|
+
css: () => new Item_1.Item({
|
|
16
|
+
loader: ({ build }) => build.loaders.css,
|
|
17
|
+
options: ({ hooks }) => ({
|
|
18
|
+
importLoaders: 1,
|
|
19
|
+
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
21
20
|
}),
|
|
22
21
|
}),
|
|
23
22
|
/**
|
|
@@ -25,11 +24,13 @@ exports.default = {
|
|
|
25
24
|
*
|
|
26
25
|
* @public
|
|
27
26
|
*/
|
|
28
|
-
|
|
27
|
+
cssModule: () => new Item_1.Item({
|
|
29
28
|
loader: ({ build }) => build.loaders.css,
|
|
30
29
|
options: ({ hooks }) => ({
|
|
31
|
-
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
32
30
|
importLoaders: 1,
|
|
31
|
+
localIdentName: '[name]__[local]___[hash:base64:5]',
|
|
32
|
+
modules: true,
|
|
33
|
+
sourceMap: hooks.filter('build.devtool') ? true : false,
|
|
33
34
|
}),
|
|
34
35
|
}),
|
|
35
36
|
/**
|
|
@@ -71,7 +72,6 @@ exports.default = {
|
|
|
71
72
|
*/
|
|
72
73
|
minicss: () => new Item_1.Item({
|
|
73
74
|
loader: ({ build }) => build.loaders.minicss,
|
|
74
|
-
options: ({ store }) => ({}),
|
|
75
75
|
}),
|
|
76
76
|
/**
|
|
77
77
|
* Factory {@link Item} for raw
|
|
@@ -89,9 +89,9 @@ exports.default = {
|
|
|
89
89
|
file: () => new Item_1.Item({
|
|
90
90
|
loader: ({ build }) => build.loaders.file,
|
|
91
91
|
options: app => ({
|
|
92
|
-
name:
|
|
93
|
-
? app.store.get('hashFormat')
|
|
94
|
-
: app.store.get('fileFormat')
|
|
92
|
+
name: app.store.is('features.hash', true)
|
|
93
|
+
? app.store.get('hashFormat').concat('.[ext]')
|
|
94
|
+
: app.store.get('fileFormat').concat('.[ext]'),
|
|
95
95
|
}),
|
|
96
96
|
}),
|
|
97
97
|
/**
|
|
@@ -101,13 +101,10 @@ exports.default = {
|
|
|
101
101
|
*/
|
|
102
102
|
[`resolve-url`]: () => new Item_1.Item({
|
|
103
103
|
loader: ({ build }) => build.loaders['resolve-url'],
|
|
104
|
-
options: ({ path, hooks }) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
sourceMap: (_a = hooks.filter('build.devtool')) !== null && _a !== void 0 ? _a : false,
|
|
109
|
-
});
|
|
110
|
-
},
|
|
104
|
+
options: ({ path, hooks }) => ({
|
|
105
|
+
root: path('src'),
|
|
106
|
+
sourceMap: hooks.filter('build.devtool') ?? false,
|
|
107
|
+
}),
|
|
111
108
|
}),
|
|
112
109
|
/**
|
|
113
110
|
* Factory {@link Item} for xml
|
|
@@ -118,4 +115,3 @@ exports.default = {
|
|
|
118
115
|
loader: ({ build }) => build.loaders.xml,
|
|
119
116
|
}),
|
|
120
117
|
};
|
|
121
|
-
//# sourceMappingURL=items.js.map
|
package/lib/cjs/Build/loaders.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
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
|
-
const
|
|
4
|
-
const mini_css_extract_plugin_1 = (0, tslib_1.__importDefault)(require("mini-css-extract-plugin"));
|
|
6
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
5
7
|
const Loader_1 = require("../Loader");
|
|
6
8
|
exports.default = {
|
|
7
9
|
/**
|
|
@@ -38,7 +40,7 @@ exports.default = {
|
|
|
38
40
|
* Returns {@link Loader} for `resolve-url-loader`
|
|
39
41
|
* @public
|
|
40
42
|
*/
|
|
41
|
-
[
|
|
43
|
+
['resolve-url']: () => new Loader_1.Loader(require.resolve('resolve-url-loader')),
|
|
42
44
|
/**
|
|
43
45
|
* Returns {@link Loader} for `style-loader`
|
|
44
46
|
* @public
|
|
@@ -55,4 +57,3 @@ exports.default = {
|
|
|
55
57
|
*/
|
|
56
58
|
xml: () => new Loader_1.Loader(require.resolve('xml-loader')),
|
|
57
59
|
};
|
|
58
|
-
//# sourceMappingURL=loaders.js.map
|
package/lib/cjs/Build/rules.js
CHANGED
|
@@ -1,143 +1,181 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toml = exports.xml = exports.csv = exports.html = exports.yml = exports.json = exports.font = exports.svg = exports.webp = exports.image = exports.cssModule = exports.css = exports.js = void 0;
|
|
4
4
|
const bud_support_1 = require("@roots/bud-support");
|
|
5
|
-
const Rule_1 = require("../Rule");
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
6
|
+
* .js rule
|
|
8
7
|
*
|
|
9
8
|
* @public
|
|
10
9
|
*/
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
? app.store.get('hashFormat')
|
|
18
|
-
: app.store.get('fileFormat')}[ext]`,
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
exports.image = image;
|
|
10
|
+
const js = (app) => app.build
|
|
11
|
+
.makeRule()
|
|
12
|
+
.setTest(({ store }) => store.get('patterns.js'))
|
|
13
|
+
.setInclude(({ path }) => path('src'))
|
|
14
|
+
.setUse([]);
|
|
15
|
+
exports.js = js;
|
|
22
16
|
/**
|
|
23
|
-
*
|
|
17
|
+
* .css rule
|
|
24
18
|
*
|
|
25
19
|
* @public
|
|
26
20
|
*/
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
})
|
|
32
|
-
|
|
21
|
+
const css = (app) => app.build
|
|
22
|
+
.makeRule()
|
|
23
|
+
.setTest(({ store }) => store.get('patterns.css'))
|
|
24
|
+
.setInclude(({ path }) => path('src'))
|
|
25
|
+
.setUse(({ isProduction, build }) => [
|
|
26
|
+
isProduction ? build.items.minicss : build.items.style,
|
|
27
|
+
build.items.css,
|
|
28
|
+
]);
|
|
29
|
+
exports.css = css;
|
|
33
30
|
/**
|
|
34
|
-
*
|
|
31
|
+
* .module.css rule
|
|
35
32
|
*
|
|
36
33
|
* @public
|
|
37
34
|
*/
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
exports.svg = svg;
|
|
35
|
+
const cssModule = (app) => app.build
|
|
36
|
+
.makeRule()
|
|
37
|
+
.setTest(({ store }) => store.get('patterns.cssModule'))
|
|
38
|
+
.setInclude(({ path }) => path('src'))
|
|
39
|
+
.setUse(({ isProduction, build }) => [
|
|
40
|
+
isProduction ? build.items.minicss : build.items.style,
|
|
41
|
+
build.items.cssModule,
|
|
42
|
+
]);
|
|
43
|
+
exports.cssModule = cssModule;
|
|
49
44
|
/**
|
|
50
|
-
*
|
|
45
|
+
* .jpg, .jpeg, .png, .gif rule
|
|
51
46
|
*
|
|
52
47
|
* @public
|
|
53
48
|
*/
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
})
|
|
58
|
-
|
|
49
|
+
const image = (app) => app.build
|
|
50
|
+
.makeRule()
|
|
51
|
+
.setTest(({ store }) => store.get('patterns.image'))
|
|
52
|
+
.setExclude(({ store }) => store.get('patterns.modules'))
|
|
53
|
+
.setType('asset/resource')
|
|
54
|
+
.setGenerator(app => ({
|
|
55
|
+
filename: app.store.is('features.hash', true)
|
|
56
|
+
? 'images/'.concat(app.store.get('hashFormat')).concat('[ext]')
|
|
57
|
+
: 'images/'.concat(app.store.get('fileFormat')).concat('[ext]'),
|
|
58
|
+
}));
|
|
59
|
+
exports.image = image;
|
|
59
60
|
/**
|
|
60
|
-
*
|
|
61
|
+
* .webp assets factorry
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* Returns {@link Rule} for `asset/resource`
|
|
61
65
|
*
|
|
62
66
|
* @public
|
|
63
67
|
*/
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
68
|
-
|
|
68
|
+
const webp = (app) => app.build
|
|
69
|
+
.makeRule()
|
|
70
|
+
.setTest(({ store }) => store.get('patterns.webp'))
|
|
71
|
+
.setExclude(({ store }) => store.get('patterns.modules'))
|
|
72
|
+
.setType('asset/resource')
|
|
73
|
+
.setGenerator(app => ({
|
|
74
|
+
filename: app.store.is('features.hash', true)
|
|
75
|
+
? 'images/'.concat(app.store.get('hashFormat')).concat('[ext]')
|
|
76
|
+
: 'images/'.concat(app.store.get('fileFormat')).concat('[ext]'),
|
|
77
|
+
}));
|
|
78
|
+
exports.webp = webp;
|
|
69
79
|
/**
|
|
70
|
-
* Returns {@link Rule} for `.
|
|
80
|
+
* Returns {@link Rule} for `.woff`/`.otf` handling
|
|
81
|
+
* .svg rule
|
|
71
82
|
*
|
|
72
83
|
* @public
|
|
73
84
|
*/
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
})
|
|
78
|
-
|
|
85
|
+
const svg = (app) => app.build
|
|
86
|
+
.makeRule()
|
|
87
|
+
.setTest(({ store }) => store.get('patterns.svg'))
|
|
88
|
+
.setExclude(({ store }) => store.get('patterns.modules'))
|
|
89
|
+
.setType('asset/resource')
|
|
90
|
+
.setGenerator(app => ({
|
|
91
|
+
filename: app.store.is('features.hash', true)
|
|
92
|
+
? 'svg/'.concat(app.store.get('hashFormat')).concat('[ext]')
|
|
93
|
+
: 'svg/'.concat(app.store.get('fileFormat')).concat('[ext]'),
|
|
94
|
+
}));
|
|
95
|
+
exports.svg = svg;
|
|
79
96
|
/**
|
|
80
|
-
*
|
|
97
|
+
* .woff, .woff2, .otf rule
|
|
81
98
|
*
|
|
82
99
|
* @public
|
|
83
100
|
*/
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
|
|
101
|
+
const font = (app) => app.build
|
|
102
|
+
.makeRule()
|
|
103
|
+
.setType('asset')
|
|
104
|
+
.setTest(({ store }) => store.get('patterns.font'))
|
|
105
|
+
.setExclude(({ store }) => store.get('patterns.modules'))
|
|
106
|
+
.setInclude(({ path }) => path('src'))
|
|
107
|
+
.setGenerator(app => ({
|
|
108
|
+
filename: app.store.is('features.hash', true)
|
|
109
|
+
? 'fonts/'.concat(app.store.get('hashFormat')).concat('[ext]')
|
|
110
|
+
: 'fonts/'.concat(app.store.get('fileFormat')).concat('[ext]'),
|
|
111
|
+
}));
|
|
112
|
+
exports.font = font;
|
|
113
|
+
/**
|
|
114
|
+
* Returns {@link Rule} for `.jsonc` handling
|
|
115
|
+
*
|
|
116
|
+
* @public
|
|
117
|
+
*/
|
|
118
|
+
const json = (app) => app.build
|
|
119
|
+
.makeRule()
|
|
120
|
+
.setType('json')
|
|
121
|
+
.setInclude(({ path }) => path('src'))
|
|
122
|
+
.setTest(({ store }) => store.get('patterns.json'))
|
|
123
|
+
.setParser({ parse: bud_support_1.json5.parse });
|
|
124
|
+
exports.json = json;
|
|
92
125
|
/**
|
|
93
126
|
* Returns {@link Rule} for `.yml` / `.yaml` handling
|
|
94
127
|
*
|
|
95
128
|
* @public
|
|
96
129
|
*/
|
|
97
|
-
const yml = () =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
});
|
|
130
|
+
const yml = (app) => app.build
|
|
131
|
+
.makeRule()
|
|
132
|
+
.setType('json')
|
|
133
|
+
.setInclude(({ path }) => path('src'))
|
|
134
|
+
.setTest(({ store }) => store.get('patterns.yml'))
|
|
135
|
+
.setParser({ parse: bud_support_1.yaml.parse });
|
|
104
136
|
exports.yml = yml;
|
|
105
137
|
/**
|
|
106
|
-
* Returns {@link Rule} for `.
|
|
138
|
+
* Returns {@link Rule} for `.html` handling
|
|
107
139
|
*
|
|
108
140
|
* @public
|
|
109
141
|
*/
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
exports.json5 = json5;
|
|
142
|
+
const html = (app) => app.build
|
|
143
|
+
.makeRule()
|
|
144
|
+
.setInclude(({ path }) => path('src'))
|
|
145
|
+
.setTest(({ store }) => store.get('patterns.html'))
|
|
146
|
+
.setUse(({ build }) => [build.items.html]);
|
|
147
|
+
exports.html = html;
|
|
118
148
|
/**
|
|
119
|
-
* Returns {@link Rule} for `.
|
|
149
|
+
* Returns {@link Rule} for `.csv` handling
|
|
120
150
|
*
|
|
121
151
|
* @public
|
|
122
152
|
*/
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
],
|
|
130
|
-
});
|
|
131
|
-
exports.css = css;
|
|
153
|
+
const csv = (app) => app.build
|
|
154
|
+
.makeRule()
|
|
155
|
+
.setInclude(({ path }) => path('src'))
|
|
156
|
+
.setTest(({ store }) => store.get('patterns.csv'))
|
|
157
|
+
.setUse(({ build }) => [build.items.csv]);
|
|
158
|
+
exports.csv = csv;
|
|
132
159
|
/**
|
|
133
|
-
* Returns {@link Rule} for `.
|
|
160
|
+
* Returns {@link Rule} for `.xml` handling
|
|
134
161
|
*
|
|
135
162
|
* @public
|
|
136
163
|
*/
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
exports.
|
|
143
|
-
|
|
164
|
+
const xml = (app) => app.build
|
|
165
|
+
.makeRule()
|
|
166
|
+
.setInclude(({ path }) => path('src'))
|
|
167
|
+
.setTest(({ store }) => store.get('patterns.xml'))
|
|
168
|
+
.setUse(({ build }) => [build.items.xml]);
|
|
169
|
+
exports.xml = xml;
|
|
170
|
+
/**
|
|
171
|
+
* Returns {@link Rule} for `.toml` handling
|
|
172
|
+
*
|
|
173
|
+
* @public
|
|
174
|
+
*/
|
|
175
|
+
const toml = (app) => app.build
|
|
176
|
+
.makeRule()
|
|
177
|
+
.setType('json')
|
|
178
|
+
.setInclude(({ path }) => path('src'))
|
|
179
|
+
.setTest(({ store }) => store.get('patterns.html'))
|
|
180
|
+
.setParser({ parse: bud_support_1.toml.parse });
|
|
181
|
+
exports.toml = toml;
|