piral-cli-webpack5 0.14.5-beta.3339 → 0.14.5
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/README.md +0 -4
- package/extend-config.js +2 -2
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +11 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
- package/package.json +3 -3
- package/src/enhancers/html5-entry-webpack-config-enhancer/index.ts +11 -1
package/README.md
CHANGED
|
@@ -42,10 +42,6 @@ Right now it includes:
|
|
|
42
42
|
|
|
43
43
|
As such it should be prepared to include assets (images, videos, ...), stylesheets (CSS and SASS), and work with TypeScript.
|
|
44
44
|
|
|
45
|
-
> Right now the output of this plugin is for the **v1** pilet schema only!
|
|
46
|
-
|
|
47
|
-
No support for the legacy **v0** pilet schema.
|
|
48
|
-
|
|
49
45
|
### Customizing
|
|
50
46
|
|
|
51
47
|
You can still leverage your own `webpack.config.js`. Either just export *what you want to have overwritten*, e.g.,
|
package/extend-config.js
CHANGED
|
@@ -98,7 +98,7 @@ module.exports = function (override) {
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
if ('rules' in override && Array.isArray(override.rules)) {
|
|
101
|
-
config.module.rules.push(...rules);
|
|
101
|
+
config.module.rules.push(...override.rules);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
if ('removeRules' in override && Array.isArray(override.removeRules)) {
|
|
@@ -106,7 +106,7 @@ module.exports = function (override) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
if ('plugins' in override && Array.isArray(override.plugins)) {
|
|
109
|
-
config.plugins.push(...plugins);
|
|
109
|
+
config.plugins.push(...override.plugins);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if ('removePlugins' in override && Array.isArray(override.removePlugins)) {
|
|
@@ -11,7 +11,17 @@ const html5EntryWebpackConfigEnhancer = (options) => (compilerOptions) => {
|
|
|
11
11
|
const [template] = (0, helpers_1.getTemplates)(entry);
|
|
12
12
|
if (template) {
|
|
13
13
|
const src = (0, path_1.dirname)(template);
|
|
14
|
-
const
|
|
14
|
+
const html = (0, fs_1.readFileSync)(template, 'utf8');
|
|
15
|
+
const templateContent = (0, cheerio_1.load)(
|
|
16
|
+
// try to replace ejs tags, if any
|
|
17
|
+
html.replace(/<%=([\w\W]*?)%>/g, function (match, group) {
|
|
18
|
+
try {
|
|
19
|
+
return eval(group);
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
return match;
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
15
25
|
const entries = (0, helpers_1.extractParts)(templateContent).map((entry) => (0, path_1.join)(src, entry));
|
|
16
26
|
const plugins = [
|
|
17
27
|
new HtmlWebpackPlugin(Object.assign(Object.assign({}, options), { templateContent: templateContent.html() })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/html5-entry-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AAEzD,qCAA+B;AAC/B,2BAAkC;AAClC,+BAAqC;AACrC,uCAAmE;AAI5D,MAAM,+BAA+B,GAC1C,CAAC,OAAuC,EAAE,EAAE,CAAC,CAAC,eAA8B,EAAE,EAAE;IAC9E,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAA,sBAAY,EAAC,KAAK,CAAC,CAAC;IAEvC,IAAI,QAAQ,EAAE;QACZ,MAAM,GAAG,GAAG,IAAA,cAAO,EAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/html5-entry-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AAEzD,qCAA+B;AAC/B,2BAAkC;AAClC,+BAAqC;AACrC,uCAAmE;AAI5D,MAAM,+BAA+B,GAC1C,CAAC,O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
1
1
|
{
|
|
2
2
|
"name": "piral-cli-webpack5",
|
|
3
|
-
"version": "0.14.5
|
|
3
|
+
"version": "0.14.5",
|
|
4
4
|
"description": "Provides debug and build capabilities for pilets and Piral instances using Webpack v5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/node": "^13.9.0",
|
|
49
49
|
"@types/terser-webpack-plugin": "^5.0.0",
|
|
50
50
|
"@types/yargs": "^15.0.4",
|
|
51
|
-
"piral-cli": "0.14.5
|
|
51
|
+
"piral-cli": "^0.14.5",
|
|
52
52
|
"strip-ansi": "^3.0.0",
|
|
53
53
|
"typescript": "^4.0.2"
|
|
54
54
|
},
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"webpack": "^5.1.3",
|
|
78
78
|
"webpack-inject-plugin": "^1.5.5"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "d2c53e25895f855fb7be6f7a09afe6ebe8b599e6"
|
|
81
81
|
}
|
|
@@ -14,7 +14,17 @@ export const html5EntryWebpackConfigEnhancer =
|
|
|
14
14
|
|
|
15
15
|
if (template) {
|
|
16
16
|
const src = dirname(template);
|
|
17
|
-
const
|
|
17
|
+
const html = readFileSync(template, 'utf8');
|
|
18
|
+
const templateContent = load(
|
|
19
|
+
// try to replace ejs tags, if any
|
|
20
|
+
html.replace(/<%=([\w\W]*?)%>/g, function (match, group) {
|
|
21
|
+
try {
|
|
22
|
+
return eval(group);
|
|
23
|
+
} catch {
|
|
24
|
+
return match;
|
|
25
|
+
}
|
|
26
|
+
}),
|
|
27
|
+
);
|
|
18
28
|
const entries = extractParts(templateContent).map((entry) => join(src, entry));
|
|
19
29
|
const plugins = [
|
|
20
30
|
new HtmlWebpackPlugin({
|