piral-cli-webpack5 0.14.5-beta.3336 → 0.14.5-beta.3347
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
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.,
|
|
@@ -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,2BAA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EAAE,CAAC,IAAA,WAAI,EAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG;YACd,IAAI,iBAAiB,iCAChB,OAAO,KACV,eAAe,EAAE,eAAe,CAAC,IAAI,EAAE,IACvC;SACH,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QAElF,IAAA,oBAAU,EAAC,eAAe,EAAE,QAAQ,EAAE,OAAqC,CAAC,CAAC;QAE7E,eAAe,CAAC,OAAO,GAAG,CAAC,GAAG,eAAe,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;KACpE;IAED,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AAlCS,QAAA,+BAA+B,mCAkCxC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli-webpack5",
|
|
3
|
-
"version": "0.14.5-beta.
|
|
3
|
+
"version": "0.14.5-beta.3347",
|
|
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-beta.
|
|
51
|
+
"piral-cli": "0.14.5-beta.3347",
|
|
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": "b0f46ae0f72d5da0fbf834d5c5f553cc70aaa648"
|
|
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({
|