@best-shot/preset-web 0.11.0 → 0.11.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/index.mjs +15 -0
- package/lib/apply-set-html.mjs +12 -15
- package/package.json +3 -4
package/index.mjs
CHANGED
|
@@ -86,5 +86,20 @@ export const schema = {
|
|
|
86
86
|
],
|
|
87
87
|
},
|
|
88
88
|
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
shim: {
|
|
91
|
+
default: [
|
|
92
|
+
'(.)*-(shim|polyfill)',
|
|
93
|
+
'@babel',
|
|
94
|
+
'core-js-(.)*',
|
|
95
|
+
'core-js',
|
|
96
|
+
'object-assign',
|
|
97
|
+
'regenerator-runtime',
|
|
98
|
+
'whatwg-fetch',
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
default: {},
|
|
103
|
+
required: ['shim'],
|
|
89
104
|
},
|
|
90
105
|
};
|
package/lib/apply-set-html.mjs
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { relative, resolve } from 'path';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
|
|
4
|
-
import deepmerge from 'deepmerge';
|
|
5
4
|
import extToRegexp from 'ext-to-regexp';
|
|
6
5
|
import slash from 'slash';
|
|
7
6
|
import slashToRegexp from 'slash-to-regexp';
|
|
8
7
|
|
|
9
|
-
function mergeAll(...options) {
|
|
10
|
-
return deepmerge.all(options, {
|
|
11
|
-
arrayMerge: (destinationArray, sourceArray) => sourceArray,
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
export function setHtml({ html = {} }) {
|
|
16
9
|
return async (chain) => {
|
|
17
10
|
const mode = chain.get('mode');
|
|
@@ -36,19 +29,29 @@ export function setHtml({ html = {} }) {
|
|
|
36
29
|
index,
|
|
37
30
|
) => {
|
|
38
31
|
chain.plugin(`html-page-${index}`).use(HtmlWebpackPlugin, [
|
|
39
|
-
|
|
32
|
+
{
|
|
33
|
+
...options,
|
|
40
34
|
cache: watch,
|
|
41
35
|
minify: false,
|
|
42
36
|
title,
|
|
43
37
|
template,
|
|
44
38
|
templateParameters: {
|
|
45
39
|
title,
|
|
40
|
+
...options.templateParameters,
|
|
46
41
|
},
|
|
47
|
-
}
|
|
42
|
+
},
|
|
48
43
|
]);
|
|
49
44
|
},
|
|
50
45
|
);
|
|
51
46
|
|
|
47
|
+
if (page.some(({ tags = [] }) => tags.length > 0)) {
|
|
48
|
+
const { HtmlAddAssetWebpackPlugin } = await import(
|
|
49
|
+
'html-add-asset-webpack-plugin'
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
chain.plugin('html-add-asset').use(HtmlAddAssetWebpackPlugin);
|
|
53
|
+
}
|
|
54
|
+
|
|
52
55
|
if (minimize) {
|
|
53
56
|
const { default: HtmlMinimizerPlugin } = await import(
|
|
54
57
|
'html-minimizer-webpack-plugin'
|
|
@@ -72,12 +75,6 @@ export function setHtml({ html = {} }) {
|
|
|
72
75
|
]);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
|
-
const { HtmlAddAssetWebpackPlugin } = await import(
|
|
76
|
-
'html-add-asset-webpack-plugin'
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
chain.plugin('html-add-asset').use(HtmlAddAssetWebpackPlugin);
|
|
80
|
-
|
|
81
78
|
if (mode === 'production') {
|
|
82
79
|
chain.output.crossOriginLoading('anonymous');
|
|
83
80
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@best-shot/preset-web",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "A `best-shot` preset for web project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -31,9 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"main": "index.mjs",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"deepmerge": "^4.2.2",
|
|
35
34
|
"ext-to-regexp": "^0.1.0",
|
|
36
|
-
"html-add-asset-webpack-plugin": "^0.
|
|
35
|
+
"html-add-asset-webpack-plugin": "^0.1.1",
|
|
37
36
|
"html-minimizer-webpack-plugin": "^3.5.0",
|
|
38
37
|
"html-webpack-plugin": "^5.5.0",
|
|
39
38
|
"micro-tpl-loader": "^0.1.0",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"webpack-subresource-integrity": "^5.1.0"
|
|
44
43
|
},
|
|
45
44
|
"peerDependencies": {
|
|
46
|
-
"@best-shot/core": "^0.6.
|
|
45
|
+
"@best-shot/core": "^0.6.10",
|
|
47
46
|
"webpack": "^5.70.0"
|
|
48
47
|
},
|
|
49
48
|
"engines": {
|