@best-shot/preset-web 0.12.7 → 0.12.8
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/index.mjs +20 -3
- package/lib/apply-split-chunks.mjs +1 -1
- package/package.json +2 -2
package/index.mjs
CHANGED
|
@@ -14,7 +14,7 @@ function addMin(filename) {
|
|
|
14
14
|
return suffix(filename, '.min');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function apply({ config: { html, vendors } }) {
|
|
17
|
+
export function apply({ config: { html, vendors, optimization = {} } }) {
|
|
18
18
|
return async (chain) => {
|
|
19
19
|
const mode = chain.get('mode');
|
|
20
20
|
const minimize = chain.optimization.get('minimize');
|
|
@@ -28,14 +28,19 @@ export function apply({ config: { html, vendors } }) {
|
|
|
28
28
|
chain
|
|
29
29
|
.when(minimize, setOutputName({ style: addMin, script: addMin }))
|
|
30
30
|
.when(!hot, setOutputName({ style: addHash, script: addHash }))
|
|
31
|
-
.
|
|
31
|
+
.when(
|
|
32
|
+
optimization.splitChunks || optimization.runtimeChunk,
|
|
32
33
|
setOutputName({
|
|
33
34
|
script: (filename) => `script/${filename}`,
|
|
34
35
|
style: (filename) => `style/${filename}`,
|
|
35
36
|
}),
|
|
36
37
|
);
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
chain.optimization.runtimeChunk(optimization.runtimeChunk);
|
|
40
|
+
|
|
41
|
+
if (optimization.splitChunks !== false) {
|
|
42
|
+
await splitChunks({ vendors })(chain);
|
|
43
|
+
}
|
|
39
44
|
|
|
40
45
|
await setHtml({ html })(chain);
|
|
41
46
|
};
|
|
@@ -104,4 +109,16 @@ export const schema = {
|
|
|
104
109
|
default: {},
|
|
105
110
|
required: ['shim'],
|
|
106
111
|
},
|
|
112
|
+
optimization: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
runtimeChunk: {
|
|
116
|
+
default: true,
|
|
117
|
+
anyOf: [{ type: 'boolean' }, { type: 'string' }],
|
|
118
|
+
},
|
|
119
|
+
splitChunks: {
|
|
120
|
+
type: 'boolean',
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
107
124
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@best-shot/preset-web",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.8",
|
|
4
4
|
"description": "A `best-shot` preset for web project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"slash": "^5.1.0",
|
|
40
40
|
"slash-to-regexp": "^0.0.4",
|
|
41
41
|
"suffix": "^1.0.0",
|
|
42
|
-
"webpack-subresource-integrity": "
|
|
42
|
+
"webpack-subresource-integrity": "5.2.0-rc.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@best-shot/core": "^0.7 || ^0.8",
|