@jsenv/plugin-minification 1.3.2 → 1.4.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/plugin-minification",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"html-minifier": "4.0.0",
|
|
28
|
-
"lightningcss": "1.
|
|
29
|
-
"terser": "5.
|
|
28
|
+
"lightningcss": "1.21.5",
|
|
29
|
+
"terser": "5.18.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@jsenv/core": "*"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
2
|
|
|
3
|
-
export const minifyCss = async (
|
|
3
|
+
export const minifyCss = async (cssUrlInfo) => {
|
|
4
4
|
const { transform } = await import("lightningcss");
|
|
5
5
|
|
|
6
|
-
const targets = runtimeCompatToTargets(context.runtimeCompat);
|
|
6
|
+
const targets = runtimeCompatToTargets(cssUrlInfo.context.runtimeCompat);
|
|
7
7
|
const { code, map } = transform({
|
|
8
8
|
filename: fileURLToPath(cssUrlInfo.originalUrl),
|
|
9
9
|
code: Buffer.from(cssUrlInfo.content),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
|
|
3
3
|
// https://github.com/kangax/html-minifier#options-quick-reference
|
|
4
|
-
export const minifyHtml = (
|
|
4
|
+
export const minifyHtml = (htmlUrlInfo, options = {}) => {
|
|
5
5
|
const require = createRequire(import.meta.url);
|
|
6
6
|
const { minify } = require("html-minifier");
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://github.com/terser-js/terser#minify-options
|
|
2
2
|
|
|
3
|
-
export const minifyJs = async (
|
|
3
|
+
export const minifyJs = async (jsUrlInfo, options) => {
|
|
4
4
|
const url = jsUrlInfo.url;
|
|
5
5
|
const content = jsUrlInfo.content;
|
|
6
6
|
const sourcemap = jsUrlInfo.sourcemap;
|
|
@@ -12,52 +12,22 @@ export const jsenvPluginMinification = ({
|
|
|
12
12
|
svg = {},
|
|
13
13
|
} = {}) => {
|
|
14
14
|
const htmlMinifier = html
|
|
15
|
-
? (urlInfo,
|
|
16
|
-
minifyHtml({
|
|
17
|
-
htmlUrlInfo: urlInfo,
|
|
18
|
-
context,
|
|
19
|
-
options: html === true ? {} : html,
|
|
20
|
-
})
|
|
15
|
+
? (urlInfo) => minifyHtml(urlInfo, html === true ? {} : html)
|
|
21
16
|
: null;
|
|
22
17
|
const svgMinifier = svg
|
|
23
|
-
? (urlInfo,
|
|
24
|
-
minifyHtml({
|
|
25
|
-
htmlUrlInfo: urlInfo,
|
|
26
|
-
context,
|
|
27
|
-
options: svg === true ? {} : svg,
|
|
28
|
-
})
|
|
18
|
+
? (urlInfo) => minifyHtml(urlInfo, svg === true ? {} : svg)
|
|
29
19
|
: null;
|
|
30
20
|
const cssMinifier = css
|
|
31
|
-
? (urlInfo,
|
|
32
|
-
minifyCss({
|
|
33
|
-
cssUrlInfo: urlInfo,
|
|
34
|
-
context,
|
|
35
|
-
options: css === true ? {} : css,
|
|
36
|
-
})
|
|
21
|
+
? (urlInfo) => minifyCss(urlInfo, css === true ? {} : css)
|
|
37
22
|
: null;
|
|
38
23
|
const jsClassicMinifier = js_classic
|
|
39
|
-
? (urlInfo,
|
|
40
|
-
minifyJs({
|
|
41
|
-
jsUrlInfo: urlInfo,
|
|
42
|
-
context,
|
|
43
|
-
options: js_classic === true ? {} : js_classic,
|
|
44
|
-
})
|
|
24
|
+
? (urlInfo) => minifyJs(urlInfo, js_classic === true ? {} : js_classic)
|
|
45
25
|
: null;
|
|
46
26
|
const jsModuleMinifier = js_module
|
|
47
|
-
? (urlInfo,
|
|
48
|
-
minifyJs({
|
|
49
|
-
jsUrlInfo: urlInfo,
|
|
50
|
-
context,
|
|
51
|
-
options: js_module === true ? {} : js_module,
|
|
52
|
-
})
|
|
27
|
+
? (urlInfo) => minifyJs(urlInfo, js_module === true ? {} : js_module)
|
|
53
28
|
: null;
|
|
54
29
|
const jsonMinifier = json
|
|
55
|
-
? (urlInfo,
|
|
56
|
-
minifyJson({
|
|
57
|
-
jsonUrlInfo: urlInfo,
|
|
58
|
-
context,
|
|
59
|
-
options: json === true ? {} : html,
|
|
60
|
-
})
|
|
30
|
+
? (urlInfo) => minifyJson(urlInfo, json === true ? {} : html)
|
|
61
31
|
: null;
|
|
62
32
|
|
|
63
33
|
return {
|