@best-shot/preset-web 0.14.8 → 0.14.10
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 +4 -6
- package/lib/apply-set-html.mjs +3 -14
- package/package.json +4 -4
package/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { setOutputName } from './lib/apply-set-output-name.mjs';
|
|
|
5
5
|
import { splitChunks } from './lib/apply-split-chunks.mjs';
|
|
6
6
|
|
|
7
7
|
function addHash(filename) {
|
|
8
|
-
return filename.includes('
|
|
8
|
+
return filename.includes('contenthash')
|
|
9
9
|
? filename
|
|
10
10
|
: suffix(filename, '.[contenthash]');
|
|
11
11
|
}
|
|
@@ -14,16 +14,14 @@ function addMin(filename) {
|
|
|
14
14
|
return suffix(filename, '.min');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function apply({ config: { html, vendors, optimization = {} } }) {
|
|
17
|
+
export function apply({ cwd, config: { html, vendors, optimization = {} } }) {
|
|
18
18
|
return async (chain) => {
|
|
19
19
|
const mode = chain.get('mode');
|
|
20
20
|
const minimize = chain.optimization.get('minimize');
|
|
21
21
|
const serve = chain.devServer.entries() !== undefined;
|
|
22
22
|
const hot = (serve && chain.devServer.get('hot')) || false;
|
|
23
23
|
|
|
24
|
-
chain.devtool(
|
|
25
|
-
mode === 'production' ? false : serve ? 'eval-source-map' : 'source-map',
|
|
26
|
-
);
|
|
24
|
+
chain.devtool(mode === 'production' ? false : 'source-map');
|
|
27
25
|
|
|
28
26
|
chain
|
|
29
27
|
.when(minimize, setOutputName({ style: addMin, script: addMin }))
|
|
@@ -41,7 +39,7 @@ export function apply({ config: { html, vendors, optimization = {} } }) {
|
|
|
41
39
|
await splitChunks({ vendors })(chain);
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
await setHtml({ html })(chain);
|
|
42
|
+
await setHtml({ cwd, html })(chain);
|
|
45
43
|
|
|
46
44
|
if (mode === 'production') {
|
|
47
45
|
const {
|
package/lib/apply-set-html.mjs
CHANGED
|
@@ -22,20 +22,16 @@ const darkTag = {
|
|
|
22
22
|
`,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
export function setHtml({ html = {} }) {
|
|
25
|
+
export function setHtml({ cwd, html = {} }) {
|
|
26
26
|
return async (chain) => {
|
|
27
27
|
const mode = chain.get('mode');
|
|
28
28
|
const watch = chain.get('watch');
|
|
29
|
-
const context = chain.get('context');
|
|
30
29
|
const minimize = chain.optimization.get('minimize');
|
|
31
30
|
|
|
32
31
|
const { default: HtmlWebpackPlugin } = await import('html-webpack-plugin');
|
|
33
32
|
|
|
34
33
|
const defaultTemplate = slash(
|
|
35
|
-
relative(
|
|
36
|
-
context,
|
|
37
|
-
fileURLToPath(new URL('template.html', import.meta.url)),
|
|
38
|
-
),
|
|
34
|
+
relative(cwd, fileURLToPath(new URL('template.html', import.meta.url))),
|
|
39
35
|
);
|
|
40
36
|
|
|
41
37
|
const isModule = chain.output.get('module');
|
|
@@ -112,14 +108,7 @@ export function setHtml({ html = {} }) {
|
|
|
112
108
|
.rule('micro-tpl')
|
|
113
109
|
.test(extToRegexp({ extname: ['html', 'htm'] }))
|
|
114
110
|
.use('micro-tpl-loader')
|
|
115
|
-
.loader('micro-tpl-loader');
|
|
116
|
-
|
|
117
|
-
chain.resolveLoader.modules.prepend(
|
|
118
|
-
relative(
|
|
119
|
-
context,
|
|
120
|
-
fileURLToPath(new URL('../node_modules', import.meta.url)),
|
|
121
|
-
),
|
|
122
|
-
);
|
|
111
|
+
.loader(fileURLToPath(import.meta.resolve('micro-tpl-loader')));
|
|
123
112
|
|
|
124
113
|
if (!watch && chain.module.rules.has('babel')) {
|
|
125
114
|
chain.module
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@best-shot/preset-web",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.10",
|
|
4
4
|
"description": "A `best-shot` preset for web project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"webpack-subresource-integrity": "5.2.0-rc.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"webpack": "^5.
|
|
47
|
-
"@best-shot/core": "
|
|
46
|
+
"webpack": "^5.92.1",
|
|
47
|
+
"@best-shot/core": "~0.9.15"
|
|
48
48
|
},
|
|
49
49
|
"engines": {
|
|
50
|
-
"node": ">=20.
|
|
50
|
+
"node": ">=20.6.0 || ^18.19.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public",
|