piral-cli-webpack5 0.15.10-beta.5463 → 0.15.10-beta.5491
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/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js +34 -6
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
- package/lib/plugins/StylesLoader.d.ts +1 -0
- package/lib/plugins/StylesLoader.js +14 -0
- package/lib/plugins/StylesLoader.js.map +1 -0
- package/lib/plugins/StylesPlugin.d.ts +6 -0
- package/lib/plugins/StylesPlugin.js +34 -0
- package/lib/plugins/StylesPlugin.js.map +1 -0
- package/lib/webpack/bundler-run.js +4 -2
- package/lib/webpack/bundler-run.js.map +1 -1
- package/lib/webpack/common.d.ts +4 -3
- package/lib/webpack/common.js +6 -11
- package/lib/webpack/common.js.map +1 -1
- package/lib/webpack/pilet.js +3 -2
- package/lib/webpack/pilet.js.map +1 -1
- package/lib/webpack/piral.js +3 -2
- package/lib/webpack/piral.js.map +1 -1
- package/package.json +3 -3
- package/src/enhancers/pilet-webpack-config-enhancer/index.ts +46 -4
- package/src/plugins/StylesLoader.ts +11 -0
- package/src/plugins/StylesPlugin.ts +35 -0
- package/src/webpack/bundler-run.ts +5 -2
- package/src/webpack/common.ts +5 -12
- package/src/webpack/pilet.ts +5 -3
- package/src/webpack/piral.ts +5 -3
|
@@ -24,7 +24,7 @@ export interface PiletWebpackConfigEnhancerOptions {
|
|
|
24
24
|
/**
|
|
25
25
|
* The schema version. By default, v1 is used.
|
|
26
26
|
*/
|
|
27
|
-
schema?: 'v0' | 'v1' | 'v2' | 'none';
|
|
27
|
+
schema?: 'v0' | 'v1' | 'v2' | 'v3' | 'none';
|
|
28
28
|
/**
|
|
29
29
|
* The shared dependencies. By default, these are read from the
|
|
30
30
|
* Piral instance.
|
|
@@ -4,6 +4,9 @@ exports.piletWebpackConfigEnhancer = void 0;
|
|
|
4
4
|
const SystemJSPublicPathWebpackPlugin = require("systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin");
|
|
5
5
|
const webpack_1 = require("webpack");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
|
+
const StylesPlugin_1 = require("../../plugins/StylesPlugin");
|
|
8
|
+
const SheetPlugin_1 = require("../../plugins/SheetPlugin");
|
|
9
|
+
const piletCss = 'main.css';
|
|
7
10
|
function piletVxWebpackConfigEnhancer(options, compiler) {
|
|
8
11
|
const { variables, externals } = options;
|
|
9
12
|
(0, helpers_1.withSetPath)(compiler);
|
|
@@ -13,14 +16,14 @@ function piletVxWebpackConfigEnhancer(options, compiler) {
|
|
|
13
16
|
return compiler;
|
|
14
17
|
}
|
|
15
18
|
function piletV0WebpackConfigEnhancer(options, compiler) {
|
|
16
|
-
const { name, variables, externals, file } = options;
|
|
19
|
+
const { name, variables, externals, file, entry } = options;
|
|
17
20
|
const shortName = name.replace(/\W/gi, '');
|
|
18
21
|
const jsonpFunction = `pr_${shortName}`;
|
|
19
22
|
const banner = `//@pilet v:0`;
|
|
20
23
|
(0, helpers_1.withSetPath)(compiler);
|
|
21
24
|
(0, helpers_1.setEnvironment)(variables);
|
|
22
25
|
(0, helpers_1.withExternals)(compiler, externals);
|
|
23
|
-
compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
26
|
+
compiler.plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
24
27
|
banner,
|
|
25
28
|
entryOnly: true,
|
|
26
29
|
include: file,
|
|
@@ -32,14 +35,14 @@ function piletV0WebpackConfigEnhancer(options, compiler) {
|
|
|
32
35
|
return compiler;
|
|
33
36
|
}
|
|
34
37
|
function piletV1WebpackConfigEnhancer(options, compiler) {
|
|
35
|
-
const { name, variables, externals, file } = options;
|
|
38
|
+
const { name, variables, externals, file, entry } = options;
|
|
36
39
|
const shortName = name.replace(/\W/gi, '');
|
|
37
40
|
const jsonpFunction = `pr_${shortName}`;
|
|
38
41
|
const banner = `//@pilet v:1(${jsonpFunction})`;
|
|
39
42
|
(0, helpers_1.withSetPath)(compiler);
|
|
40
43
|
(0, helpers_1.setEnvironment)(variables);
|
|
41
44
|
(0, helpers_1.withExternals)(compiler, externals);
|
|
42
|
-
compiler.plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
45
|
+
compiler.plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
43
46
|
banner,
|
|
44
47
|
entryOnly: true,
|
|
45
48
|
include: file,
|
|
@@ -54,7 +57,7 @@ function piletV1WebpackConfigEnhancer(options, compiler) {
|
|
|
54
57
|
return compiler;
|
|
55
58
|
}
|
|
56
59
|
function piletV2WebpackConfigEnhancer(options, compiler) {
|
|
57
|
-
const { name, variables, externals, file, importmap } = options;
|
|
60
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
58
61
|
const shortName = name.replace(/\W/gi, '');
|
|
59
62
|
const jsonpFunction = `pr_${shortName}`;
|
|
60
63
|
const plugins = [];
|
|
@@ -62,7 +65,7 @@ function piletV2WebpackConfigEnhancer(options, compiler) {
|
|
|
62
65
|
(0, helpers_1.setEnvironment)(variables);
|
|
63
66
|
const dependencies = (0, helpers_1.getDependencies)(importmap, compiler);
|
|
64
67
|
const banner = `//@pilet v:2(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
65
|
-
plugins.push(new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
68
|
+
plugins.push(new SheetPlugin_1.default(piletCss, name, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
66
69
|
banner,
|
|
67
70
|
entryOnly: true,
|
|
68
71
|
include: file,
|
|
@@ -73,6 +76,29 @@ function piletV2WebpackConfigEnhancer(options, compiler) {
|
|
|
73
76
|
compiler.output.library = { type: 'system' };
|
|
74
77
|
return compiler;
|
|
75
78
|
}
|
|
79
|
+
function piletV3WebpackConfigEnhancer(options, compiler) {
|
|
80
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
81
|
+
const shortName = name.replace(/\W/gi, '');
|
|
82
|
+
const jsonpFunction = `pr_${shortName}`;
|
|
83
|
+
const plugins = [];
|
|
84
|
+
(0, helpers_1.withExternals)(compiler, externals);
|
|
85
|
+
(0, helpers_1.setEnvironment)(variables);
|
|
86
|
+
const dependencies = (0, helpers_1.getDependencies)(importmap, compiler);
|
|
87
|
+
const banner = `//@pilet v:3(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
88
|
+
plugins.push(new StylesPlugin_1.default(piletCss, entry), new webpack_1.DefinePlugin((0, helpers_1.getDefineVariables)(variables)), new webpack_1.BannerPlugin({
|
|
89
|
+
banner,
|
|
90
|
+
entryOnly: true,
|
|
91
|
+
include: file,
|
|
92
|
+
raw: true,
|
|
93
|
+
}));
|
|
94
|
+
compiler.output.publicPath = '';
|
|
95
|
+
compiler.output.chunkFormat = 'module';
|
|
96
|
+
compiler.plugins = [...compiler.plugins, ...plugins];
|
|
97
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
98
|
+
compiler.output.library = { type: 'system' };
|
|
99
|
+
compiler.target = 'node';
|
|
100
|
+
return compiler;
|
|
101
|
+
}
|
|
76
102
|
const piletWebpackConfigEnhancer = (details) => (compiler) => {
|
|
77
103
|
const { externals = [], schema, importmap } = details;
|
|
78
104
|
const environment = process.env.NODE_ENV || 'development';
|
|
@@ -91,6 +117,8 @@ const piletWebpackConfigEnhancer = (details) => (compiler) => {
|
|
|
91
117
|
return piletV1WebpackConfigEnhancer(options, compiler);
|
|
92
118
|
case 'v2':
|
|
93
119
|
return piletV2WebpackConfigEnhancer(options, compiler);
|
|
120
|
+
case 'v3':
|
|
121
|
+
return piletV3WebpackConfigEnhancer(options, compiler);
|
|
94
122
|
case 'none':
|
|
95
123
|
default:
|
|
96
124
|
return piletVxWebpackConfigEnhancer(options, compiler);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,4GAA4G;AAE5G,qCAAoE;AACpE,uCAOmB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/enhancers/pilet-webpack-config-enhancer/index.ts"],"names":[],"mappings":";;;AAAA,4GAA4G;AAE5G,qCAAoE;AACpE,uCAOmB;AACnB,6DAAsD;AACtD,2DAAoD;AAEpD,MAAM,QAAQ,GAAG,UAAU,CAAC;AAmD5B,SAAS,4BAA4B,CAAC,OAA8B,EAAE,QAAuB;IAC3F,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEzC,IAAA,qBAAW,EAAC,QAAQ,CAAC,CAAC;IACtB,IAAA,wBAAc,EAAC,SAAS,CAAC,CAAC;IAC1B,IAAA,uBAAa,EAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEnC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,sBAAY,CAAC,IAAA,4BAAkB,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAEvE,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,4BAA4B,CAAC,OAA8B,EAAE,QAAuB;IAC3F,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,MAAM,SAAS,EAAE,CAAC;IACxC,MA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,CAAC;QACzD,KAAK,IAAI;YACP,OAAO,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzD,KAAK,IAAI;YACP,OAAO,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzD,KAAK,MAAM,CAAC;QACZ;YACE,OAAO,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;KAC1D;AACH,CAAC,CAAC;AA5BW,QAAA,0BAA0B,8BA4BrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function stylesLoader(): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const loader_utils_1 = require("loader-utils");
|
|
4
|
+
function stylesLoader() {
|
|
5
|
+
const { cssName, entries } = (0, loader_utils_1.getOptions)(this);
|
|
6
|
+
const debug = process.env.NODE_ENV === 'development';
|
|
7
|
+
return [
|
|
8
|
+
`const u = ${JSON.stringify(cssName)}`,
|
|
9
|
+
`export const styles = [${debug ? 'u+"?_="+Math.random()' : 'u'}]`,
|
|
10
|
+
...entries.split(',').map((entry) => `export * from ${JSON.stringify(entry)}`),
|
|
11
|
+
].join(';');
|
|
12
|
+
}
|
|
13
|
+
exports.default = stylesLoader;
|
|
14
|
+
//# sourceMappingURL=StylesLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StylesLoader.js","sourceRoot":"","sources":["../../src/plugins/StylesLoader.ts"],"names":[],"mappings":";;AAAA,+CAA0C;AAE1C,SAAwB,YAAY;IAClC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IACrD,OAAO;QACL,aAAa,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACtC,0BAA0B,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,GAAG,GAAG;QAClE,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;KAC/E,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACd,CAAC;AARD,+BAQC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path_1 = require("path");
|
|
4
|
+
const webpack_1 = require("webpack");
|
|
5
|
+
const webpack_sources_1 = require("webpack-sources");
|
|
6
|
+
class StylesPlugin {
|
|
7
|
+
constructor(cssName, entryName) {
|
|
8
|
+
this.cssName = cssName;
|
|
9
|
+
this.entryName = entryName;
|
|
10
|
+
}
|
|
11
|
+
apply(compiler) {
|
|
12
|
+
const { entry } = compiler.options;
|
|
13
|
+
const entries = entry[this.entryName].import;
|
|
14
|
+
const query = `cssName=${this.cssName}&entries=${entries.join(',')}!`;
|
|
15
|
+
const setPath = (0, path_1.resolve)(__dirname, '..', 'set-path');
|
|
16
|
+
const loaderPath = (0, path_1.resolve)(__dirname, `StylesLoader?${query}`);
|
|
17
|
+
entry[this.entryName].import = [setPath, loaderPath];
|
|
18
|
+
compiler.hooks.compilation.tap('StylesPlugin', (compilation) => {
|
|
19
|
+
if (!compilation.compiler.parentCompilation) {
|
|
20
|
+
compilation.hooks.processAssets.tap({
|
|
21
|
+
name: 'StylesPlugin',
|
|
22
|
+
stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
23
|
+
}, (assets) => {
|
|
24
|
+
if (!assets[this.cssName]) {
|
|
25
|
+
const source = new webpack_sources_1.RawSource('');
|
|
26
|
+
compilation.emitAsset(this.cssName, source);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = StylesPlugin;
|
|
34
|
+
//# sourceMappingURL=StylesPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StylesPlugin.js","sourceRoot":"","sources":["../../src/plugins/StylesPlugin.ts"],"names":[],"mappings":";;AAAA,+BAA+B;AAC/B,qCAAsC;AACtC,qDAA4C;AAE5C,MAAqB,YAAY;IAC/B,YAAoB,OAAe,EAAU,SAAiB;QAA1C,YAAO,GAAP,OAAO,CAAQ;QAAU,cAAS,GAAT,SAAS,CAAQ;IAAG,CAAC;IAElE,KAAK,CAAC,QAAQ;QACZ,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC;QAEnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC;QAC7C,MAAM,KAAK,GAAG,WAAW,IAAI,CAAC,OAAO,YAAY,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QACtE,MAAM,OAAO,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QACrD,MAAM,UAAU,GAAG,IAAA,cAAO,EAAC,SAAS,EAAE,gBAAgB,KAAK,EAAE,CAAC,CAAC;QAE/D,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAErD,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC,WAAwB,EAAE,EAAE;YAC1E,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,EAAE;gBAC3C,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CACjC;oBACE,IAAI,EAAE,cAAc;oBACpB,KAAK,EAAE,qBAAW,CAAC,8BAA8B;iBAClD,EACD,CAAC,MAAM,EAAE,EAAE;oBACT,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;wBACzB,MAAM,MAAM,GAAG,IAAI,2BAAS,CAAC,EAAE,CAAC,CAAC;wBACjC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;qBAC7C;gBACH,CAAC,CACF,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA9BD,+BA8BC"}
|
|
@@ -8,8 +8,10 @@ function getOutput(stats) {
|
|
|
8
8
|
const { outputPath, entrypoints } = stats.toJson();
|
|
9
9
|
for (const name of Object.keys(entrypoints)) {
|
|
10
10
|
const assets = entrypoints[name].assets;
|
|
11
|
-
const firstAsset = assets
|
|
12
|
-
|
|
11
|
+
const firstAsset = assets.find((m) => m.name.endsWith('.js') || m.name.endsWith('.mjs'));
|
|
12
|
+
if (firstAsset) {
|
|
13
|
+
return (0, path_1.resolve)(outputPath, firstAsset.name);
|
|
14
|
+
}
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
function getPreset(logLevel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-run.js","sourceRoot":"","sources":["../../src/webpack/bundler-run.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,+BAAkD;AAClD,mCAAsC;AAGtC,SAAS,SAAS,CAAC,KAAoB;IACrC,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;IAEnD,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC3C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACxC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"bundler-run.js","sourceRoot":"","sources":["../../src/webpack/bundler-run.ts"],"names":[],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Q,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;oBAC/C,IAAI,GAAG,EAAE;wBACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;wBACnB,MAAM,CAAC,GAAG,CAAC,CAAC;qBACb;yBAAM;wBACL,OAAO,CAAC,GAAG,CACT,KAAK,CAAC,QAAQ,iCACT,MAAM,CAAC,OAAO,KACjB,MAAM,EAAE,IAAI,IACZ,CACH,CAAC;wBAEF,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE;4BACrB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;yBACtC;6BAAM;4BACL,YAAY,CAAC,KAAK,CAAC,CAAC;4BACpB,OAAO,CAAC,MAAM,CAAC,CAAC;yBACjB;qBACF;gBACH,CAAC,CAAC,CAAC;gBAEH,IAAI,OAAO,EAAE;oBACX,2CAA2C;oBAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;oBAChD,MAAM,CAAC,OAAO,GAAG,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;iBACtE;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,CAAC,EAAE;YACR,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC/B,CAAC;QACD,KAAK,CAAC,EAAE;YACN,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC;AA3ED,gCA2EC"}
|
package/lib/webpack/common.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { RuleSetRule, Configuration } from 'webpack';
|
|
1
|
+
import { RuleSetRule, WebpackPluginInstance, Configuration } from 'webpack';
|
|
2
|
+
export declare function getStyleLoaders(useExtractLoader: boolean): string[];
|
|
2
3
|
export declare type ConfigEnhancer = (config: Configuration) => Configuration;
|
|
3
4
|
export declare type DefaultConfiguration = [Configuration, ConfigEnhancer];
|
|
4
5
|
export declare const extensions: string[];
|
|
5
6
|
export declare function getVariables(): Record<string, string>;
|
|
6
|
-
export declare function getPlugins(plugins: Array<
|
|
7
|
-
export declare function getRules(
|
|
7
|
+
export declare function getPlugins(plugins: Array<WebpackPluginInstance>, pilet?: string): WebpackPluginInstance[];
|
|
8
|
+
export declare function getRules(styleLoaders: Array<string>): Array<RuleSetRule>;
|
package/lib/webpack/common.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRules = exports.getPlugins = exports.getVariables = exports.extensions = void 0;
|
|
3
|
+
exports.getRules = exports.getPlugins = exports.getVariables = exports.extensions = exports.getStyleLoaders = void 0;
|
|
4
4
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
5
5
|
const utils_1 = require("piral-cli/utils");
|
|
6
6
|
const webpack_1 = require("webpack");
|
|
7
|
-
const SheetPlugin_1 = require("../plugins/SheetPlugin");
|
|
8
7
|
const piletCss = 'main.css';
|
|
9
|
-
function getStyleLoaders(
|
|
10
|
-
if (
|
|
8
|
+
function getStyleLoaders(useExtractLoader) {
|
|
9
|
+
if (useExtractLoader) {
|
|
11
10
|
return [MiniCssExtractPlugin.loader];
|
|
12
11
|
}
|
|
13
12
|
else {
|
|
14
13
|
return [require.resolve('style-loader')];
|
|
15
14
|
}
|
|
16
15
|
}
|
|
16
|
+
exports.getStyleLoaders = getStyleLoaders;
|
|
17
17
|
exports.extensions = ['.ts', '.tsx', '.js', '.jsx', '.json'];
|
|
18
18
|
function getVariables() {
|
|
19
19
|
return Object.keys(process.env).reduce((prev, curr) => {
|
|
@@ -22,7 +22,7 @@ function getVariables() {
|
|
|
22
22
|
}, {});
|
|
23
23
|
}
|
|
24
24
|
exports.getVariables = getVariables;
|
|
25
|
-
function getPlugins(plugins,
|
|
25
|
+
function getPlugins(plugins, pilet) {
|
|
26
26
|
const otherPlugins = [
|
|
27
27
|
new MiniCssExtractPlugin({
|
|
28
28
|
filename: pilet ? piletCss : '[name].[fullhash:6].css',
|
|
@@ -40,15 +40,10 @@ function getPlugins(plugins, production, pilet) {
|
|
|
40
40
|
}
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
|
-
if (production && pilet) {
|
|
44
|
-
const name = process.env.BUILD_PCKG_NAME;
|
|
45
|
-
otherPlugins.push(new SheetPlugin_1.default(piletCss, name, pilet));
|
|
46
|
-
}
|
|
47
43
|
return plugins.concat(otherPlugins);
|
|
48
44
|
}
|
|
49
45
|
exports.getPlugins = getPlugins;
|
|
50
|
-
function getRules(
|
|
51
|
-
const styleLoaders = getStyleLoaders(production);
|
|
46
|
+
function getRules(styleLoaders) {
|
|
52
47
|
const nodeModules = /node_modules/;
|
|
53
48
|
const babelLoader = {
|
|
54
49
|
loader: require.resolve('babel-loader'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/webpack/common.ts"],"names":[],"mappings":";;;AAAA,gEAAgE;AAChE,2CAA0D;AAC1D,qCAA4F;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/webpack/common.ts"],"names":[],"mappings":";;;AAAA,gEAAgE;AAChE,2CAA0D;AAC1D,qCAA4F;AAE5F,MAAM,QAAQ,GAAG,UAAU,CAAC;AAE5B,SAAgB,eAAe,CAAC,gBAAyB;IACvD,IAAI,gBAAgB,EAAE;QACpB,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;KACtC;SAAM;QACL,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC;KAC1C;AACH,CAAC;AAND,0CAMC;AAMY,QAAA,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAElE,SAAgB,YAAY;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zDD,4BAyDC"}
|
package/lib/webpack/pilet.js
CHANGED
|
@@ -35,6 +35,7 @@ function getConfig(template, dist, filename, externals, importmap = [], piralIns
|
|
|
35
35
|
filename,
|
|
36
36
|
variables: (0, common_1.getVariables)(),
|
|
37
37
|
});
|
|
38
|
+
const styleLoaders = (0, common_1.getStyleLoaders)(true);
|
|
38
39
|
return [
|
|
39
40
|
{
|
|
40
41
|
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
@@ -53,7 +54,7 @@ function getConfig(template, dist, filename, externals, importmap = [], piralIns
|
|
|
53
54
|
extensions: common_1.extensions,
|
|
54
55
|
},
|
|
55
56
|
module: {
|
|
56
|
-
rules: (0, common_1.getRules)(
|
|
57
|
+
rules: (0, common_1.getRules)(styleLoaders),
|
|
57
58
|
},
|
|
58
59
|
optimization: {
|
|
59
60
|
minimize,
|
|
@@ -73,7 +74,7 @@ function getConfig(template, dist, filename, externals, importmap = [], piralIns
|
|
|
73
74
|
new CssMinimizerPlugin(),
|
|
74
75
|
],
|
|
75
76
|
},
|
|
76
|
-
plugins: (0, common_1.getPlugins)([],
|
|
77
|
+
plugins: (0, common_1.getPlugins)([], entry),
|
|
77
78
|
},
|
|
78
79
|
enhance,
|
|
79
80
|
];
|
package/lib/webpack/pilet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pilet.js","sourceRoot":"","sources":["../../src/webpack/pilet.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,sDAAsD;AACtD,mEAAmE;AAEnE,
|
|
1
|
+
{"version":3,"file":"pilet.js","sourceRoot":"","sources":["../../src/webpack/pilet.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,sDAAsD;AACtD,mEAAmE;AAEnE,qCAAiH;AACjH,8FAAwF;AACxF,+BAA+B;AAC/B,+CAA2C;AAC3C,4CAAoD;AACpD,wCAA0C;AAE1C,SAAe,SAAS,CACtB,QAAgB,EAChB,IAAY,EACZ,QAAgB,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AAC;AAEW,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC"}
|
package/lib/webpack/piral.js
CHANGED
|
@@ -36,6 +36,7 @@ function getConfig(template, dist, externals, develop = false, sourceMaps = true
|
|
|
36
36
|
variables: (0, common_1.getVariables)(),
|
|
37
37
|
}),
|
|
38
38
|
].reduceRight((acc, val) => val(acc), options);
|
|
39
|
+
const styleLoaders = (0, common_1.getStyleLoaders)(production);
|
|
39
40
|
return [
|
|
40
41
|
{
|
|
41
42
|
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
@@ -51,7 +52,7 @@ function getConfig(template, dist, externals, develop = false, sourceMaps = true
|
|
|
51
52
|
extensions: common_1.extensions,
|
|
52
53
|
},
|
|
53
54
|
module: {
|
|
54
|
-
rules: (0, common_1.getRules)(
|
|
55
|
+
rules: (0, common_1.getRules)(styleLoaders),
|
|
55
56
|
},
|
|
56
57
|
optimization: {
|
|
57
58
|
minimize,
|
|
@@ -65,7 +66,7 @@ function getConfig(template, dist, externals, develop = false, sourceMaps = true
|
|
|
65
66
|
new CssMinimizerPlugin(),
|
|
66
67
|
],
|
|
67
68
|
},
|
|
68
|
-
plugins: (0, common_1.getPlugins)([]
|
|
69
|
+
plugins: (0, common_1.getPlugins)([]),
|
|
69
70
|
},
|
|
70
71
|
enhance,
|
|
71
72
|
];
|
package/lib/webpack/piral.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"piral.js","sourceRoot":"","sources":["../../src/webpack/piral.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sDAAsD;AACtD,mEAAmE;AACnE,2CAA8C;AAC9C,+BAA+B;AAC/B,+CAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"piral.js","sourceRoot":"","sources":["../../src/webpack/piral.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,sDAAsD;AACtD,mEAAmE;AACnE,2CAA8C;AAC9C,+BAA+B;AAC/B,+CAA2C;AA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,QAAQ,GAAG,IAAA,sBAAY,EAAC,UAAU,EAAE,eAAe,EAAE;gBACzD,KAAK,EAAE,OAAO,CAAC,KAAK;aACrB,CAAC,CAAC;YAEH,OAAO,IAAA,wBAAU,EAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAChD,CAAC;KAAA;CACF,CAAC;AAEW,QAAA,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-cli-webpack5",
|
|
3
|
-
"version": "0.15.10-beta.
|
|
3
|
+
"version": "0.15.10-beta.5491",
|
|
4
4
|
"description": "Provides debug and build capabilities for pilets and Piral instances using Webpack v5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"@types/node": "^13.9.0",
|
|
50
50
|
"@types/terser-webpack-plugin": "^5.0.0",
|
|
51
51
|
"@types/yargs": "^15.0.4",
|
|
52
|
-
"piral-cli": "0.15.10-beta.
|
|
52
|
+
"piral-cli": "0.15.10-beta.5491",
|
|
53
53
|
"strip-ansi": "^3.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"ts-loader": "^8.0.6",
|
|
77
77
|
"webpack": "^5.1.3"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "3ee67d02efb34989f4642076e302e0813d28bcc1"
|
|
80
80
|
}
|
|
@@ -9,6 +9,10 @@ import {
|
|
|
9
9
|
withExternals,
|
|
10
10
|
getDependencies,
|
|
11
11
|
} from './helpers';
|
|
12
|
+
import StylesPlugin from '../../plugins/StylesPlugin';
|
|
13
|
+
import SheetPlugin from '../../plugins/SheetPlugin';
|
|
14
|
+
|
|
15
|
+
const piletCss = 'main.css';
|
|
12
16
|
|
|
13
17
|
export interface PiletWebpackConfigEnhancerOptions {
|
|
14
18
|
/**
|
|
@@ -34,7 +38,7 @@ export interface PiletWebpackConfigEnhancerOptions {
|
|
|
34
38
|
/**
|
|
35
39
|
* The schema version. By default, v1 is used.
|
|
36
40
|
*/
|
|
37
|
-
schema?: 'v0' | 'v1' | 'v2' | 'none';
|
|
41
|
+
schema?: 'v0' | 'v1' | 'v2' | 'v3' | 'none';
|
|
38
42
|
/**
|
|
39
43
|
* The shared dependencies. By default, these are read from the
|
|
40
44
|
* Piral instance.
|
|
@@ -72,7 +76,7 @@ function piletVxWebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
72
76
|
}
|
|
73
77
|
|
|
74
78
|
function piletV0WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler: Configuration) {
|
|
75
|
-
const { name, variables, externals, file } = options;
|
|
79
|
+
const { name, variables, externals, file, entry } = options;
|
|
76
80
|
const shortName = name.replace(/\W/gi, '');
|
|
77
81
|
const jsonpFunction = `pr_${shortName}`;
|
|
78
82
|
const banner = `//@pilet v:0`;
|
|
@@ -82,6 +86,7 @@ function piletV0WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
82
86
|
withExternals(compiler, externals);
|
|
83
87
|
|
|
84
88
|
compiler.plugins.push(
|
|
89
|
+
new SheetPlugin(piletCss, name, entry),
|
|
85
90
|
new DefinePlugin(getDefineVariables(variables)),
|
|
86
91
|
new BannerPlugin({
|
|
87
92
|
banner,
|
|
@@ -98,7 +103,7 @@ function piletV0WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
function piletV1WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler: Configuration) {
|
|
101
|
-
const { name, variables, externals, file } = options;
|
|
106
|
+
const { name, variables, externals, file, entry } = options;
|
|
102
107
|
const shortName = name.replace(/\W/gi, '');
|
|
103
108
|
const jsonpFunction = `pr_${shortName}`;
|
|
104
109
|
const banner = `//@pilet v:1(${jsonpFunction})`;
|
|
@@ -108,6 +113,7 @@ function piletV1WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
108
113
|
withExternals(compiler, externals);
|
|
109
114
|
|
|
110
115
|
compiler.plugins.push(
|
|
116
|
+
new SheetPlugin(piletCss, name, entry),
|
|
111
117
|
new DefinePlugin(getDefineVariables(variables)),
|
|
112
118
|
new BannerPlugin({
|
|
113
119
|
banner,
|
|
@@ -127,7 +133,7 @@ function piletV1WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
function piletV2WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler: Configuration) {
|
|
130
|
-
const { name, variables, externals, file, importmap } = options;
|
|
136
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
131
137
|
const shortName = name.replace(/\W/gi, '');
|
|
132
138
|
const jsonpFunction = `pr_${shortName}`;
|
|
133
139
|
const plugins = [];
|
|
@@ -139,6 +145,7 @@ function piletV2WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
139
145
|
const banner = `//@pilet v:2(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
140
146
|
|
|
141
147
|
plugins.push(
|
|
148
|
+
new SheetPlugin(piletCss, name, entry),
|
|
142
149
|
new DefinePlugin(getDefineVariables(variables)),
|
|
143
150
|
new BannerPlugin({
|
|
144
151
|
banner,
|
|
@@ -156,6 +163,39 @@ function piletV2WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler:
|
|
|
156
163
|
return compiler;
|
|
157
164
|
}
|
|
158
165
|
|
|
166
|
+
function piletV3WebpackConfigEnhancer(options: SchemaEnhancerOptions, compiler: Configuration) {
|
|
167
|
+
const { name, variables, externals, file, importmap, entry } = options;
|
|
168
|
+
const shortName = name.replace(/\W/gi, '');
|
|
169
|
+
const jsonpFunction = `pr_${shortName}`;
|
|
170
|
+
const plugins = [];
|
|
171
|
+
|
|
172
|
+
withExternals(compiler, externals);
|
|
173
|
+
setEnvironment(variables);
|
|
174
|
+
|
|
175
|
+
const dependencies = getDependencies(importmap, compiler);
|
|
176
|
+
const banner = `//@pilet v:3(webpackChunk${jsonpFunction},${JSON.stringify(dependencies)})`;
|
|
177
|
+
|
|
178
|
+
plugins.push(
|
|
179
|
+
new StylesPlugin(piletCss, entry),
|
|
180
|
+
new DefinePlugin(getDefineVariables(variables)),
|
|
181
|
+
new BannerPlugin({
|
|
182
|
+
banner,
|
|
183
|
+
entryOnly: true,
|
|
184
|
+
include: file,
|
|
185
|
+
raw: true,
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
compiler.output.publicPath = '';
|
|
190
|
+
compiler.output.chunkFormat = 'module';
|
|
191
|
+
compiler.plugins = [...compiler.plugins, ...plugins];
|
|
192
|
+
compiler.output.uniqueName = `${jsonpFunction}`;
|
|
193
|
+
compiler.output.library = { type: 'system' };
|
|
194
|
+
compiler.target = 'node';
|
|
195
|
+
|
|
196
|
+
return compiler;
|
|
197
|
+
}
|
|
198
|
+
|
|
159
199
|
export const piletWebpackConfigEnhancer = (details: PiletWebpackConfigEnhancerOptions) => (compiler: Configuration) => {
|
|
160
200
|
const { externals = [], schema, importmap } = details;
|
|
161
201
|
const environment = process.env.NODE_ENV || 'development';
|
|
@@ -178,6 +218,8 @@ export const piletWebpackConfigEnhancer = (details: PiletWebpackConfigEnhancerOp
|
|
|
178
218
|
return piletV1WebpackConfigEnhancer(options, compiler);
|
|
179
219
|
case 'v2':
|
|
180
220
|
return piletV2WebpackConfigEnhancer(options, compiler);
|
|
221
|
+
case 'v3':
|
|
222
|
+
return piletV3WebpackConfigEnhancer(options, compiler);
|
|
181
223
|
case 'none':
|
|
182
224
|
default:
|
|
183
225
|
return piletVxWebpackConfigEnhancer(options, compiler);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getOptions } from 'loader-utils';
|
|
2
|
+
|
|
3
|
+
export default function stylesLoader() {
|
|
4
|
+
const { cssName, entries } = getOptions(this);
|
|
5
|
+
const debug = process.env.NODE_ENV === 'development';
|
|
6
|
+
return [
|
|
7
|
+
`const u = ${JSON.stringify(cssName)}`,
|
|
8
|
+
`export const styles = [${debug ? 'u+"?_="+Math.random()' : 'u'}]`,
|
|
9
|
+
...entries.split(',').map((entry) => `export * from ${JSON.stringify(entry)}`),
|
|
10
|
+
].join(';');
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { Compilation } from 'webpack';
|
|
3
|
+
import { RawSource } from 'webpack-sources';
|
|
4
|
+
|
|
5
|
+
export default class StylesPlugin {
|
|
6
|
+
constructor(private cssName: string, private entryName: string) {}
|
|
7
|
+
|
|
8
|
+
apply(compiler) {
|
|
9
|
+
const { entry } = compiler.options;
|
|
10
|
+
|
|
11
|
+
const entries = entry[this.entryName].import;
|
|
12
|
+
const query = `cssName=${this.cssName}&entries=${entries.join(',')}!`;
|
|
13
|
+
const setPath = resolve(__dirname, '..', 'set-path');
|
|
14
|
+
const loaderPath = resolve(__dirname, `StylesLoader?${query}`);
|
|
15
|
+
|
|
16
|
+
entry[this.entryName].import = [setPath, loaderPath];
|
|
17
|
+
|
|
18
|
+
compiler.hooks.compilation.tap('StylesPlugin', (compilation: Compilation) => {
|
|
19
|
+
if (!compilation.compiler.parentCompilation) {
|
|
20
|
+
compilation.hooks.processAssets.tap(
|
|
21
|
+
{
|
|
22
|
+
name: 'StylesPlugin',
|
|
23
|
+
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
24
|
+
},
|
|
25
|
+
(assets) => {
|
|
26
|
+
if (!assets[this.cssName]) {
|
|
27
|
+
const source = new RawSource('');
|
|
28
|
+
compilation.emitAsset(this.cssName, source);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -8,8 +8,11 @@ function getOutput(stats: webpack.Stats) {
|
|
|
8
8
|
|
|
9
9
|
for (const name of Object.keys(entrypoints)) {
|
|
10
10
|
const assets = entrypoints[name].assets;
|
|
11
|
-
const firstAsset = assets
|
|
12
|
-
|
|
11
|
+
const firstAsset = assets.find((m) => m.name.endsWith('.js') || m.name.endsWith('.mjs'));
|
|
12
|
+
|
|
13
|
+
if (firstAsset) {
|
|
14
|
+
return resolve(outputPath, firstAsset.name);
|
|
15
|
+
}
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
|
package/src/webpack/common.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
2
2
|
import { progress, logReset, log } from 'piral-cli/utils';
|
|
3
3
|
import { RuleSetRule, ProgressPlugin, WebpackPluginInstance, Configuration } from 'webpack';
|
|
4
|
-
import SheetPlugin from '../plugins/SheetPlugin';
|
|
5
4
|
|
|
6
5
|
const piletCss = 'main.css';
|
|
7
6
|
|
|
8
|
-
function getStyleLoaders(
|
|
9
|
-
if (
|
|
7
|
+
export function getStyleLoaders(useExtractLoader: boolean) {
|
|
8
|
+
if (useExtractLoader) {
|
|
10
9
|
return [MiniCssExtractPlugin.loader];
|
|
11
10
|
} else {
|
|
12
11
|
return [require.resolve('style-loader')];
|
|
@@ -26,12 +25,12 @@ export function getVariables(): Record<string, string> {
|
|
|
26
25
|
}, {});
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export function getPlugins(plugins: Array<
|
|
28
|
+
export function getPlugins(plugins: Array<WebpackPluginInstance>, pilet?: string) {
|
|
30
29
|
const otherPlugins: Array<WebpackPluginInstance> = [
|
|
31
30
|
new MiniCssExtractPlugin({
|
|
32
31
|
filename: pilet ? piletCss : '[name].[fullhash:6].css',
|
|
33
32
|
chunkFilename: '[id].[chunkhash:6].css',
|
|
34
|
-
})
|
|
33
|
+
}),
|
|
35
34
|
];
|
|
36
35
|
|
|
37
36
|
if (process.env.WEBPACK_PROGRESS) {
|
|
@@ -49,16 +48,10 @@ export function getPlugins(plugins: Array<any>, production: boolean, pilet?: str
|
|
|
49
48
|
);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
if (production && pilet) {
|
|
53
|
-
const name = process.env.BUILD_PCKG_NAME;
|
|
54
|
-
otherPlugins.push(new SheetPlugin(piletCss, name, pilet) as any);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
51
|
return plugins.concat(otherPlugins);
|
|
58
52
|
}
|
|
59
53
|
|
|
60
|
-
export function getRules(
|
|
61
|
-
const styleLoaders = getStyleLoaders(production);
|
|
54
|
+
export function getRules(styleLoaders: Array<string>): Array<RuleSetRule> {
|
|
62
55
|
const nodeModules = /node_modules/;
|
|
63
56
|
const babelLoader = {
|
|
64
57
|
loader: require.resolve('babel-loader'),
|
package/src/webpack/pilet.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { PiletBuildHandler } from 'piral-cli';
|
|
|
2
2
|
import * as TerserPlugin from 'terser-webpack-plugin';
|
|
3
3
|
import * as CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
4
4
|
import type { PiletSchemaVersion, SharedDependency } from 'piral-cli';
|
|
5
|
-
import { getRules, getPlugins, extensions, getVariables, DefaultConfiguration } from './common';
|
|
5
|
+
import { getRules, getPlugins, extensions, getVariables, DefaultConfiguration, getStyleLoaders } from './common';
|
|
6
6
|
import { piletWebpackConfigEnhancer } from '../enhancers/pilet-webpack-config-enhancer';
|
|
7
7
|
import { resolve } from 'path';
|
|
8
8
|
import { runWebpack } from './bundler-run';
|
|
@@ -39,6 +39,8 @@ async function getConfig(
|
|
|
39
39
|
variables: getVariables(),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
+
const styleLoaders = getStyleLoaders(true);
|
|
43
|
+
|
|
42
44
|
return [
|
|
43
45
|
{
|
|
44
46
|
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
@@ -63,7 +65,7 @@ async function getConfig(
|
|
|
63
65
|
},
|
|
64
66
|
|
|
65
67
|
module: {
|
|
66
|
-
rules: getRules(
|
|
68
|
+
rules: getRules(styleLoaders),
|
|
67
69
|
},
|
|
68
70
|
|
|
69
71
|
optimization: {
|
|
@@ -85,7 +87,7 @@ async function getConfig(
|
|
|
85
87
|
],
|
|
86
88
|
},
|
|
87
89
|
|
|
88
|
-
plugins: getPlugins([],
|
|
90
|
+
plugins: getPlugins([], entry),
|
|
89
91
|
},
|
|
90
92
|
enhance,
|
|
91
93
|
];
|
package/src/webpack/piral.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
|
|
|
5
5
|
import { getFreePort } from 'piral-cli/utils';
|
|
6
6
|
import { resolve } from 'path';
|
|
7
7
|
import { runWebpack } from './bundler-run';
|
|
8
|
-
import { getRules, getPlugins, extensions, getVariables, DefaultConfiguration } from './common';
|
|
8
|
+
import { getRules, getPlugins, extensions, getVariables, DefaultConfiguration, getStyleLoaders } from './common';
|
|
9
9
|
import { html5EntryWebpackConfigEnhancer } from '../enhancers/html5-entry-webpack-config-enhancer';
|
|
10
10
|
import { piralInstanceWebpackConfigEnhancer } from '../enhancers/piral-instance-webpack-config-enhancer';
|
|
11
11
|
import { hmrWebpackConfigEnhancer } from '../enhancers/hmr-webpack-config-enhancer';
|
|
@@ -39,6 +39,8 @@ async function getConfig(
|
|
|
39
39
|
}),
|
|
40
40
|
].reduceRight((acc, val) => val(acc), options);
|
|
41
41
|
|
|
42
|
+
const styleLoaders = getStyleLoaders(production);
|
|
43
|
+
|
|
42
44
|
return [
|
|
43
45
|
{
|
|
44
46
|
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
@@ -59,7 +61,7 @@ async function getConfig(
|
|
|
59
61
|
},
|
|
60
62
|
|
|
61
63
|
module: {
|
|
62
|
-
rules: getRules(
|
|
64
|
+
rules: getRules(styleLoaders),
|
|
63
65
|
},
|
|
64
66
|
|
|
65
67
|
optimization: {
|
|
@@ -75,7 +77,7 @@ async function getConfig(
|
|
|
75
77
|
],
|
|
76
78
|
},
|
|
77
79
|
|
|
78
|
-
plugins: getPlugins([]
|
|
80
|
+
plugins: getPlugins([]),
|
|
79
81
|
},
|
|
80
82
|
enhance,
|
|
81
83
|
];
|