piral-cli-webpack5 1.0.0-pre.1960 → 1.0.1-beta.5640
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/LICENSE +1 -1
- package/README.md +31 -10
- package/extend-config.js +125 -18
- package/lib/actions.d.ts +2 -2
- package/lib/actions.js +33 -39
- package/lib/actions.js.map +1 -1
- package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.js +1 -1
- package/lib/enhancers/hmr-webpack-config-enhancer/HotModuleServerPlugin.js.map +1 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.d.ts +5 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.js +30 -0
- package/lib/enhancers/hmr-webpack-config-enhancer/index.js.map +1 -0
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.d.ts +2 -2
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js +1 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.d.ts +2 -1
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js +17 -6
- package/lib/enhancers/html5-entry-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.d.ts +5 -0
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js +53 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/pilet-webpack-config-enhancer/index.d.ts +18 -4
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js +117 -49
- package/lib/enhancers/pilet-webpack-config-enhancer/index.js.map +1 -1
- package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js +2 -0
- package/lib/enhancers/piral-instance-webpack-config-enhancer/helpers.js.map +1 -1
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.d.ts +2 -3
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js +6 -7
- package/lib/enhancers/piral-instance-webpack-config-enhancer/index.js.map +1 -1
- package/lib/helpers.d.ts +2 -1
- package/lib/helpers.js +10 -4
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/plugins/SheetLoader.d.ts +1 -0
- package/lib/plugins/SheetLoader.js +19 -0
- package/lib/plugins/SheetLoader.js.map +1 -0
- package/lib/plugins/SheetPlugin.d.ts +7 -0
- package/lib/plugins/SheetPlugin.js +31 -0
- package/lib/plugins/SheetPlugin.js.map +1 -0
- 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.d.ts +2 -21
- package/lib/webpack/bundler-run.js +54 -46
- package/lib/webpack/bundler-run.js.map +1 -1
- package/lib/webpack/common.d.ts +8 -0
- package/lib/webpack/common.js +104 -0
- package/lib/webpack/common.js.map +1 -0
- package/lib/webpack/pilet.d.ts +19 -0
- package/lib/webpack/pilet.js +97 -0
- package/lib/webpack/pilet.js.map +1 -0
- package/lib/webpack/piral.d.ts +16 -0
- package/lib/webpack/piral.js +90 -0
- package/lib/webpack/piral.js.map +1 -0
- package/package.json +28 -29
- package/src/actions.ts +33 -20
- package/src/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.ts +1 -1
- package/src/enhancers/hmr-webpack-config-enhancer/index.ts +34 -0
- package/src/enhancers/html5-entry-webpack-config-enhancer/helpers.ts +7 -7
- package/src/enhancers/html5-entry-webpack-config-enhancer/index.ts +31 -19
- package/src/enhancers/pilet-webpack-config-enhancer/helpers.ts +62 -0
- package/src/enhancers/pilet-webpack-config-enhancer/index.ts +187 -59
- package/src/enhancers/piral-instance-webpack-config-enhancer/helpers.ts +2 -0
- package/src/enhancers/piral-instance-webpack-config-enhancer/index.ts +14 -18
- package/src/helpers.ts +15 -5
- package/src/index.ts +1 -1
- package/src/plugins/SheetLoader.ts +16 -0
- package/src/plugins/SheetPlugin.ts +34 -0
- package/src/plugins/StylesLoader.ts +11 -0
- package/src/plugins/StylesPlugin.ts +35 -0
- package/src/webpack/bundler-run.ts +60 -56
- package/src/webpack/common.ts +111 -0
- package/src/webpack/pilet.ts +121 -0
- package/src/webpack/piral.ts +110 -0
- package/src/webpack-hot-middleware/LICENSE +20 -0
- package/src/webpack-hot-middleware/client-overlay.js +99 -0
- package/src/webpack-hot-middleware/client.js +306 -0
- package/src/webpack-hot-middleware/helpers.js +9 -0
- package/src/webpack-hot-middleware/middleware.js +175 -0
- package/src/webpack-hot-middleware/process-update.js +157 -0
- package/lib/configs/HotModuleServerPlugin.js.map +0 -1
- package/lib/configs/SheetLoader.d.ts +0 -1
- package/lib/configs/SheetLoader.js +0 -27
- package/lib/configs/SheetLoader.js.map +0 -1
- package/lib/configs/common.d.ts +0 -6
- package/lib/configs/common.js +0 -115
- package/lib/configs/common.js.map +0 -1
- package/lib/configs/index.d.ts +0 -2
- package/lib/configs/index.js +0 -15
- package/lib/configs/index.js.map +0 -1
- package/lib/configs/pilet.d.ts +0 -3
- package/lib/configs/pilet.js +0 -72
- package/lib/configs/pilet.js.map +0 -1
- package/lib/configs/piral.d.ts +0 -2
- package/lib/configs/piral.js +0 -65
- package/lib/configs/piral.js.map +0 -1
- package/lib/webpack/bundler-calls.d.ts +0 -3
- package/lib/webpack/bundler-calls.js +0 -93
- package/lib/webpack/bundler-calls.js.map +0 -1
- package/lib/webpack/index.d.ts +0 -1
- package/lib/webpack/index.js +0 -14
- package/lib/webpack/index.js.map +0 -1
- package/lib/webpack/run-build-pilet.d.ts +0 -1
- package/lib/webpack/run-build-pilet.js +0 -53
- package/lib/webpack/run-build-pilet.js.map +0 -1
- package/lib/webpack/run-build-piral.d.ts +0 -1
- package/lib/webpack/run-build-piral.js +0 -56
- package/lib/webpack/run-build-piral.js.map +0 -1
- package/lib/webpack/run-debug-mono-piral.d.ts +0 -1
- package/lib/webpack/run-debug-mono-piral.js +0 -61
- package/lib/webpack/run-debug-mono-piral.js.map +0 -1
- package/lib/webpack/run-debug-pilet.d.ts +0 -1
- package/lib/webpack/run-debug-pilet.js +0 -77
- package/lib/webpack/run-debug-pilet.js.map +0 -1
- package/lib/webpack/run-debug-piral.d.ts +0 -1
- package/lib/webpack/run-debug-piral.js +0 -76
- package/lib/webpack/run-debug-piral.js.map +0 -1
- package/src/configs/SheetLoader.ts +0 -12
- package/src/configs/common.ts +0 -118
- package/src/configs/index.ts +0 -2
- package/src/configs/pilet.ts +0 -82
- package/src/configs/piral.ts +0 -73
- package/src/webpack/bundler-calls.ts +0 -107
- package/src/webpack/index.ts +0 -1
- package/src/webpack/run-build-pilet.ts +0 -82
- package/src/webpack/run-build-piral.ts +0 -83
- package/src/webpack/run-debug-mono-piral.ts +0 -76
- package/src/webpack/run-debug-pilet.ts +0 -94
- package/src/webpack/run-debug-piral.ts +0 -95
- /package/lib/{configs → enhancers/hmr-webpack-config-enhancer}/HotModuleServerPlugin.d.ts +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundler-run.js","sourceRoot":"","sources":["../../src/webpack/bundler-run.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AACnC,+BAAkD;AAClD,mCAAsC;
|
|
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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BAEF,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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RuleSetRule, WebpackPluginInstance, Configuration } from 'webpack';
|
|
2
|
+
export declare function getStyleLoaders(useExtractLoader: boolean): string[];
|
|
3
|
+
export type ConfigEnhancer = (config: Configuration) => Configuration;
|
|
4
|
+
export type DefaultConfiguration = [Configuration, ConfigEnhancer];
|
|
5
|
+
export declare const extensions: string[];
|
|
6
|
+
export declare function getVariables(): Record<string, string>;
|
|
7
|
+
export declare function getPlugins(plugins: Array<WebpackPluginInstance>, pilet?: string): WebpackPluginInstance[];
|
|
8
|
+
export declare function getRules(styleLoaders: Array<string>): Array<RuleSetRule>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRules = exports.getPlugins = exports.getVariables = exports.extensions = exports.getStyleLoaders = void 0;
|
|
4
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
5
|
+
const utils_1 = require("piral-cli/utils");
|
|
6
|
+
const webpack_1 = require("webpack");
|
|
7
|
+
const piletCss = 'main.css';
|
|
8
|
+
function getStyleLoaders(useExtractLoader) {
|
|
9
|
+
if (useExtractLoader) {
|
|
10
|
+
return [MiniCssExtractPlugin.loader];
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return [require.resolve('style-loader')];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.getStyleLoaders = getStyleLoaders;
|
|
17
|
+
exports.extensions = ['.ts', '.tsx', '.js', '.jsx', '.json'];
|
|
18
|
+
function getVariables() {
|
|
19
|
+
return Object.keys(process.env).reduce((prev, curr) => {
|
|
20
|
+
prev[curr] = process.env[curr];
|
|
21
|
+
return prev;
|
|
22
|
+
}, {});
|
|
23
|
+
}
|
|
24
|
+
exports.getVariables = getVariables;
|
|
25
|
+
function getPlugins(plugins, pilet) {
|
|
26
|
+
const otherPlugins = [
|
|
27
|
+
new MiniCssExtractPlugin({
|
|
28
|
+
filename: pilet ? piletCss : '[name].[fullhash:6].css',
|
|
29
|
+
chunkFilename: '[id].[chunkhash:6].css',
|
|
30
|
+
}),
|
|
31
|
+
];
|
|
32
|
+
if (process.env.WEBPACK_PROGRESS) {
|
|
33
|
+
otherPlugins.push(new webpack_1.ProgressPlugin((percent, msg) => {
|
|
34
|
+
if (percent !== undefined) {
|
|
35
|
+
(0, utils_1.progress)(`${~~(percent * 100)}% : ${msg}`);
|
|
36
|
+
if (percent === 1) {
|
|
37
|
+
(0, utils_1.logReset)();
|
|
38
|
+
(0, utils_1.log)('generalInfo_0000', 'Bundling finished.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return plugins.concat(otherPlugins);
|
|
44
|
+
}
|
|
45
|
+
exports.getPlugins = getPlugins;
|
|
46
|
+
function getRules(styleLoaders) {
|
|
47
|
+
const nodeModules = /node_modules/;
|
|
48
|
+
const babelLoader = {
|
|
49
|
+
loader: require.resolve('babel-loader'),
|
|
50
|
+
options: {
|
|
51
|
+
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
const tsLoader = {
|
|
55
|
+
loader: require.resolve('ts-loader'),
|
|
56
|
+
options: {
|
|
57
|
+
transpileOnly: true,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
return [
|
|
61
|
+
{
|
|
62
|
+
oneOf: [
|
|
63
|
+
{
|
|
64
|
+
test: /\.s[ac]ss$/i,
|
|
65
|
+
use: [...styleLoaders, require.resolve('css-loader'), require.resolve('sass-loader')],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
test: /\.css$/i,
|
|
69
|
+
use: [...styleLoaders, require.resolve('css-loader')],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
test: /\.m?jsx?$/i,
|
|
73
|
+
use: [babelLoader],
|
|
74
|
+
exclude: nodeModules,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
test: /\.tsx?$/i,
|
|
78
|
+
use: [babelLoader, tsLoader],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
test: /\.codegen$/i,
|
|
82
|
+
use: [require.resolve('parcel-codegen-loader')],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
test: /\.js$/i,
|
|
86
|
+
use: [require.resolve('source-map-loader')],
|
|
87
|
+
exclude: nodeModules,
|
|
88
|
+
enforce: 'pre',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
// Exclude `js` files to keep "css" loader working as it injects
|
|
92
|
+
// its runtime that would otherwise be processed through "file" loader.
|
|
93
|
+
// Also exclude `html` and `json` extensions so they get processed
|
|
94
|
+
// by webpacks internal loaders.
|
|
95
|
+
exclude: [/^$/, /\.(js|mjs|jsx|ts|tsx|vue|svelte|elm)$/i, /\.html$/i, /\.json$/i],
|
|
96
|
+
type: 'asset/resource',
|
|
97
|
+
},
|
|
98
|
+
// Don't add new loaders here -> should be added before the last (catch-all) handler
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
exports.getRules = getRules;
|
|
104
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;IAC1B,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACpD,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AALD,oCAKC;AAED,SAAgB,UAAU,CAAC,OAAqC,EAAE,KAAc;IAC9E,MAAM,YAAY,GAAiC;QACjD,IAAI,oBAAoB,CAAC;YACvB,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,yBAAyB;YACt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AAS;oBACf,GAAG,EAAE,CAAC,GAAG,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;iBACtD;gBACD;oBACE,IAAI,EAAE,YAAY;oBAClB,GAAG,EAAE,CAAC,WAAW,CAAC;oBAClB,OAAO,EAAE,WAAW;iBACrB;gBACD;oBACE,IAAI,EAAE,UAAU;oBAChB,GAAG,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC;iBAC7B;gBACD;oBACE,IAAI,EAAE,aAAa;oBACnB,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;iBAChD;gBACD;oBACE,IAAI,EAAE,QAAQ;oBACd,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;oBAC3C,OAAO,EAAE,WAAW;oBACpB,OAAO,EAAE,KAAK;iBACf;gBACD;oBACE,gEAAgE;oBAChE,uEAAuE;oBACvE,kEAAkE;oBAClE,gCAAgC;oBAChC,OAAO,EAAE,CAAC,IAAI,EAAE,wCAAwC,EAAE,UAAU,EAAE,UAAU,CAAC;oBACjF,IAAI,EAAE,gBAAgB;iBACvB;gBACD,oFAAoF;aACrF;SACF;KACF,CAAC;AACJ,CAAC;AAzDD,4BAyDC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PiletSchemaVersion, SharedDependency } from 'piral-cli';
|
|
2
|
+
export declare const create: (config: {
|
|
3
|
+
root: string;
|
|
4
|
+
piralInstances: string[];
|
|
5
|
+
entryModule: string;
|
|
6
|
+
targetDir: string;
|
|
7
|
+
outDir: string;
|
|
8
|
+
outFile: string;
|
|
9
|
+
externals: string[];
|
|
10
|
+
importmap: SharedDependency[];
|
|
11
|
+
version: PiletSchemaVersion;
|
|
12
|
+
develop: boolean;
|
|
13
|
+
sourceMaps: boolean;
|
|
14
|
+
contentHash: boolean;
|
|
15
|
+
minify: boolean;
|
|
16
|
+
logLevel: import("piral-cli").LogLevels;
|
|
17
|
+
watch: boolean;
|
|
18
|
+
args: any;
|
|
19
|
+
}) => Promise<import("piral-cli").BundleHandlerResponse>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.create = void 0;
|
|
13
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
14
|
+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
15
|
+
const common_1 = require("./common");
|
|
16
|
+
const pilet_webpack_config_enhancer_1 = require("../enhancers/pilet-webpack-config-enhancer");
|
|
17
|
+
const path_1 = require("path");
|
|
18
|
+
const bundler_run_1 = require("./bundler-run");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
const helpers_1 = require("../helpers");
|
|
21
|
+
function getConfig(template, dist, filename, externals, importmap = [], piralInstances, schema, develop = false, sourceMaps = true, contentHash = true, minimize = true) {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const production = !develop;
|
|
24
|
+
const name = process.env.BUILD_PCKG_NAME;
|
|
25
|
+
const version = process.env.BUILD_PCKG_VERSION;
|
|
26
|
+
const entry = filename.replace(/\.js$/i, '');
|
|
27
|
+
const enhance = (0, pilet_webpack_config_enhancer_1.piletWebpackConfigEnhancer)({
|
|
28
|
+
name,
|
|
29
|
+
piralInstances,
|
|
30
|
+
version,
|
|
31
|
+
entry,
|
|
32
|
+
externals,
|
|
33
|
+
importmap,
|
|
34
|
+
schema,
|
|
35
|
+
filename,
|
|
36
|
+
variables: (0, common_1.getVariables)(),
|
|
37
|
+
});
|
|
38
|
+
const styleLoaders = (0, common_1.getStyleLoaders)(true);
|
|
39
|
+
return [
|
|
40
|
+
{
|
|
41
|
+
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
42
|
+
mode: develop ? 'development' : 'production',
|
|
43
|
+
target: 'web',
|
|
44
|
+
entry: {
|
|
45
|
+
[entry]: [template],
|
|
46
|
+
},
|
|
47
|
+
output: {
|
|
48
|
+
publicPath: './',
|
|
49
|
+
path: dist,
|
|
50
|
+
filename: '[name].js',
|
|
51
|
+
chunkFilename: contentHash ? '[chunkhash:8].js' : undefined,
|
|
52
|
+
},
|
|
53
|
+
resolve: {
|
|
54
|
+
extensions: common_1.extensions,
|
|
55
|
+
},
|
|
56
|
+
module: {
|
|
57
|
+
rules: (0, common_1.getRules)(styleLoaders),
|
|
58
|
+
},
|
|
59
|
+
optimization: {
|
|
60
|
+
minimize,
|
|
61
|
+
minimizer: [
|
|
62
|
+
new TerserPlugin({
|
|
63
|
+
extractComments: false,
|
|
64
|
+
terserOptions: {
|
|
65
|
+
ie8: true,
|
|
66
|
+
output: {
|
|
67
|
+
comments: /^@pilet/,
|
|
68
|
+
},
|
|
69
|
+
mangle: {
|
|
70
|
+
reserved: ['__bundleUrl__'],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
new CssMinimizerPlugin(),
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
plugins: (0, common_1.getPlugins)([], entry),
|
|
78
|
+
},
|
|
79
|
+
enhance,
|
|
80
|
+
];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const handler = {
|
|
84
|
+
create(options) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const { config = constants_1.defaultWebpackConfig } = options.args._;
|
|
87
|
+
const otherConfigPath = (0, path_1.resolve)(options.root, config);
|
|
88
|
+
const baseConfig = yield getConfig(options.entryModule, options.outDir, options.outFile, options.externals, options.importmap, options.piralInstances, options.version, options.develop, options.sourceMaps, options.contentHash, options.minify);
|
|
89
|
+
const wpConfig = (0, helpers_1.extendConfig)(baseConfig, otherConfigPath, {
|
|
90
|
+
watch: options.watch,
|
|
91
|
+
});
|
|
92
|
+
return (0, bundler_run_1.runWebpack)(wpConfig, options.logLevel);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
exports.create = handler.create;
|
|
97
|
+
//# sourceMappingURL=pilet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAChB,SAAwB,EACxB,YAAqC,EAAE,EACvC,cAA6B,EAC7B,MAA0B,EAC1B,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,IAAI,EACjB,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI;;QAEf,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAC/C,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE7C,MAAM,OAAO,GAAG,IAAA,0DAA0B,EAAC;YACzC,IAAI;YACJ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,CAAC;CAAA;AAED,MAAM,OAAO,GAAsB;IAC3B,MAAM,CAAC,OAAO;;YAClB,MAAM,EAAE,MAAM,GAAG,gCAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YACzD,MAAM,eAAe,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtD,MAAM,UAAU,GAAG,MAAM,SAAS,CAChC,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,cAAc,EACtB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,CACf,CAAC;YACF,MAAM,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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const create: (config: {
|
|
2
|
+
root: string;
|
|
3
|
+
entryFiles: string;
|
|
4
|
+
outDir: string;
|
|
5
|
+
outFile: string;
|
|
6
|
+
externals: string[];
|
|
7
|
+
emulator: boolean;
|
|
8
|
+
sourceMaps: boolean;
|
|
9
|
+
contentHash: boolean;
|
|
10
|
+
minify: boolean;
|
|
11
|
+
publicUrl: string;
|
|
12
|
+
hmr: boolean;
|
|
13
|
+
logLevel: import("piral-cli").LogLevels;
|
|
14
|
+
watch: boolean;
|
|
15
|
+
args: any;
|
|
16
|
+
}) => Promise<import("piral-cli").BundleHandlerResponse>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.create = void 0;
|
|
13
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
14
|
+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
15
|
+
const utils_1 = require("piral-cli/utils");
|
|
16
|
+
const path_1 = require("path");
|
|
17
|
+
const bundler_run_1 = require("./bundler-run");
|
|
18
|
+
const common_1 = require("./common");
|
|
19
|
+
const html5_entry_webpack_config_enhancer_1 = require("../enhancers/html5-entry-webpack-config-enhancer");
|
|
20
|
+
const piral_instance_webpack_config_enhancer_1 = require("../enhancers/piral-instance-webpack-config-enhancer");
|
|
21
|
+
const hmr_webpack_config_enhancer_1 = require("../enhancers/hmr-webpack-config-enhancer");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
23
|
+
const helpers_1 = require("../helpers");
|
|
24
|
+
function getConfig(template, dist, externals, develop = false, sourceMaps = true, contentHash = true, minimize = true, publicPath = '/', hmr = 0) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const production = !develop;
|
|
27
|
+
const name = process.env.BUILD_PCKG_NAME;
|
|
28
|
+
const version = process.env.BUILD_PCKG_VERSION;
|
|
29
|
+
const enhance = (options) => [
|
|
30
|
+
(0, hmr_webpack_config_enhancer_1.hmrWebpackConfigEnhancer)({ port: hmr }),
|
|
31
|
+
(0, html5_entry_webpack_config_enhancer_1.html5EntryWebpackConfigEnhancer)({}),
|
|
32
|
+
(0, piral_instance_webpack_config_enhancer_1.piralInstanceWebpackConfigEnhancer)({
|
|
33
|
+
name,
|
|
34
|
+
version,
|
|
35
|
+
externals,
|
|
36
|
+
variables: (0, common_1.getVariables)(),
|
|
37
|
+
}),
|
|
38
|
+
].reduceRight((acc, val) => val(acc), options);
|
|
39
|
+
const styleLoaders = (0, common_1.getStyleLoaders)(production);
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
devtool: sourceMaps ? (develop ? 'cheap-module-source-map' : 'source-map') : false,
|
|
43
|
+
mode: develop ? 'development' : 'production',
|
|
44
|
+
entry: [template],
|
|
45
|
+
output: {
|
|
46
|
+
publicPath,
|
|
47
|
+
path: dist,
|
|
48
|
+
filename: `index.${contentHash ? '[contenthash:6].' : ''}js`,
|
|
49
|
+
chunkFilename: contentHash ? '[chunkhash:6].js' : undefined,
|
|
50
|
+
},
|
|
51
|
+
resolve: {
|
|
52
|
+
extensions: common_1.extensions,
|
|
53
|
+
},
|
|
54
|
+
module: {
|
|
55
|
+
rules: (0, common_1.getRules)(styleLoaders),
|
|
56
|
+
},
|
|
57
|
+
optimization: {
|
|
58
|
+
minimize,
|
|
59
|
+
minimizer: [
|
|
60
|
+
new TerserPlugin({
|
|
61
|
+
extractComments: false,
|
|
62
|
+
terserOptions: {
|
|
63
|
+
ie8: true,
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
new CssMinimizerPlugin(),
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
plugins: (0, common_1.getPlugins)([]),
|
|
70
|
+
},
|
|
71
|
+
enhance,
|
|
72
|
+
];
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const handler = {
|
|
76
|
+
create(options) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const { 'hmr-port': defaultHmrPort = 62123, config = constants_1.defaultWebpackConfig } = options.args._;
|
|
79
|
+
const hmrPort = options.hmr ? yield (0, utils_1.getFreePort)(defaultHmrPort) : 0;
|
|
80
|
+
const otherConfigPath = (0, path_1.resolve)(options.root, config);
|
|
81
|
+
const baseConfig = yield getConfig(options.entryFiles, options.outDir, options.externals, options.emulator, options.sourceMaps, options.contentHash, options.minify, options.publicUrl, hmrPort);
|
|
82
|
+
const wpConfig = (0, helpers_1.extendConfig)(baseConfig, otherConfigPath, {
|
|
83
|
+
watch: options.watch,
|
|
84
|
+
});
|
|
85
|
+
return (0, bundler_run_1.runWebpack)(wpConfig, options.logLevel);
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
exports.create = handler.create;
|
|
90
|
+
//# sourceMappingURL=piral.js.map
|
|
@@ -0,0 +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,qCAAiH;AACjH,0GAAmG;AACnG,gHAAyG;AACzG,0FAAoF;AACpF,4CAAoD;AACpD,wCAA0C;AAE1C,SAAe,SAAS,CACtB,QAAgB,EAChB,IAAY,EACZ,SAAwB,EACxB,OAAO,GAAG,KAAK,EACf,UAAU,GAAG,IAAI,EACjB,WAAW,GAAG,IAAI,EAClB,QAAQ,GAAG,IAAI,EACf,UAAU,GAAG,GAAG,EAChB,GAAG,GAAG,CAAC;;QAEP,MAAM,UAAU,GAAG,CAAC,OAAO,CAAC;QAC5B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;QAE/C,MAAM,OAAO,GAAG,CAAC,O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BACF;gBAED,OAAO,EAAE,IAAA,mBAAU,EAAC,EAAE,CAAC;aACxB;YACD,OAAO;SACR,CAAC;IACJ,CAAC;CAAA;AAED,MAAM,OAAO,GAAsB;IAC3B,MAAM,CAAC,OAAO;;YAClB,MAAM,EAAE,UAAU,EAAE,cAAc,GAAG,KAAK,EAAE,MAAM,GAAG,gCAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7F,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,IAAA,mBAAW,EAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACpE,MAAM,eAAe,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtD,MAAM,UAAU,GAAG,MAAM,SAAS,CAChC,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,WAAW,EACnB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CACR,CAAC;YACF,MAAM,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": "1.0.
|
|
3
|
+
"version": "1.0.1-beta.5640",
|
|
4
4
|
"description": "Provides debug and build capabilities for pilets and Piral instances using Webpack v5.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral-cli",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"main": "lib/index.js",
|
|
20
20
|
"typings": "lib/index.d.ts",
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=14.18.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"lib",
|
|
@@ -38,44 +38,43 @@
|
|
|
38
38
|
"url": "https://github.com/smapiot/piral/issues"
|
|
39
39
|
},
|
|
40
40
|
"scripts": {
|
|
41
|
+
"cleanup": "rimraf lib",
|
|
41
42
|
"build": "tsc",
|
|
42
43
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
|
-
"@types/cheerio": "0.22.21",
|
|
46
|
+
"@types/cheerio": "^0.22.21",
|
|
46
47
|
"@types/loader-utils": "^1.1.3",
|
|
47
|
-
"@types/mini-css-extract-plugin": "^
|
|
48
|
-
"@types/node": "
|
|
49
|
-
"@types/terser-webpack-plugin": "^5.
|
|
48
|
+
"@types/mini-css-extract-plugin": "^2.5.1",
|
|
49
|
+
"@types/node": "18.0.1",
|
|
50
|
+
"@types/terser-webpack-plugin": "^5.2.0",
|
|
50
51
|
"@types/yargs": "^15.0.4",
|
|
51
|
-
"piral-cli": "
|
|
52
|
-
"
|
|
52
|
+
"piral-cli": "1.0.1-beta.5640",
|
|
53
|
+
"strip-ansi": "^6.0.0"
|
|
53
54
|
},
|
|
54
55
|
"dependencies": {
|
|
55
|
-
"@babel/core": "^7.
|
|
56
|
-
"@babel/preset-env": "^7.
|
|
57
|
-
"@babel/preset-react": "^7.
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
56
|
+
"@babel/core": "^7.21.8",
|
|
57
|
+
"@babel/preset-env": "^7.21.5",
|
|
58
|
+
"@babel/preset-react": "^7.18.6",
|
|
59
|
+
"ansi-html-community": "0.0.8",
|
|
60
|
+
"babel-loader": "^9.1.2",
|
|
61
|
+
"cheerio": "^1.0.0-rc.12",
|
|
62
|
+
"css-loader": "^6.7.3",
|
|
63
|
+
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
61
64
|
"express": "^4.17.1",
|
|
62
|
-
"
|
|
63
|
-
"html-webpack-plugin": "^
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"optimize-css-assets-webpack-plugin": "^5.0.4",
|
|
69
|
-
"parcel-codegen-loader": "^0.6.4",
|
|
70
|
-
"pilet-webpack-plugin": "^0.6.4",
|
|
71
|
-
"piral-instance-webpack-plugin": "^0.6.4",
|
|
65
|
+
"html-entities": "^1.2.0",
|
|
66
|
+
"html-webpack-plugin": "^5.2.0",
|
|
67
|
+
"mini-css-extract-plugin": "^2.7.5",
|
|
68
|
+
"parcel-codegen-loader": "^0.8.3",
|
|
69
|
+
"querystring": "^0.2.0",
|
|
70
|
+
"sass": "^1.32.12",
|
|
72
71
|
"sass-loader": "^10.0.3",
|
|
73
72
|
"source-map-loader": "^1.1.1",
|
|
74
73
|
"style-loader": "^2.0.0",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"webpack
|
|
74
|
+
"systemjs-webpack-interop": "^2.3.7",
|
|
75
|
+
"terser-webpack-plugin": "^5.3.8",
|
|
76
|
+
"ts-loader": "^9.4.2",
|
|
77
|
+
"webpack": "^5.82.1"
|
|
79
78
|
},
|
|
80
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "fa0a72b28fd0a20afec7ef491ec19e93c090fc72"
|
|
81
80
|
}
|
package/src/actions.ts
CHANGED
|
@@ -1,43 +1,56 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import type {
|
|
3
3
|
DebugPiletBundlerDefinition,
|
|
4
4
|
DebugPiralBundlerDefinition,
|
|
5
5
|
BuildPiletBundlerDefinition,
|
|
6
6
|
BuildPiralBundlerDefinition,
|
|
7
7
|
WatchPiralBundlerDefinition,
|
|
8
8
|
} from 'piral-cli';
|
|
9
|
+
import { defaultWebpackConfig } from './constants';
|
|
9
10
|
|
|
10
|
-
export const
|
|
11
|
-
|
|
12
|
-
const bundler = await callDynamic('debug-piral', args);
|
|
13
|
-
return bundler;
|
|
14
|
-
},
|
|
11
|
+
export const watchPiral: WatchPiralBundlerDefinition = {
|
|
12
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
15
13
|
};
|
|
16
14
|
|
|
17
|
-
export const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
export const debugPiral: DebugPiralBundlerDefinition = {
|
|
16
|
+
flags(argv) {
|
|
17
|
+
return argv
|
|
18
|
+
.string('config')
|
|
19
|
+
.describe('config', 'Sets configuration file for modifying the Webpack configuration.')
|
|
20
|
+
.default('config', defaultWebpackConfig)
|
|
21
|
+
.number('hmr-port')
|
|
22
|
+
.describe('hmr-port', 'Sets the port to be used for HMR for reloading the application.')
|
|
23
|
+
.default('hmr-port', 62123);
|
|
21
24
|
},
|
|
25
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
22
26
|
};
|
|
23
27
|
|
|
24
28
|
export const buildPiral: BuildPiralBundlerDefinition = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
flags(argv) {
|
|
30
|
+
return argv
|
|
31
|
+
.string('config')
|
|
32
|
+
.describe('config', 'Sets configuration file for modifying the Webpack configuration.')
|
|
33
|
+
.default('config', defaultWebpackConfig);
|
|
28
34
|
},
|
|
35
|
+
path: resolve(__dirname, 'webpack', 'piral.js'),
|
|
29
36
|
};
|
|
30
37
|
|
|
31
38
|
export const debugPilet: DebugPiletBundlerDefinition = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
flags(argv) {
|
|
40
|
+
return argv
|
|
41
|
+
.string('config')
|
|
42
|
+
.describe('config', 'Sets configuration file for modifying the Webpack configuration.')
|
|
43
|
+
.default('config', defaultWebpackConfig);
|
|
35
44
|
},
|
|
45
|
+
path: resolve(__dirname, 'webpack', 'pilet.js'),
|
|
36
46
|
};
|
|
37
47
|
|
|
38
48
|
export const buildPilet: BuildPiletBundlerDefinition = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
flags(argv) {
|
|
50
|
+
return argv
|
|
51
|
+
.string('config')
|
|
52
|
+
.describe('config', 'Sets configuration file for modifying the Webpack configuration.')
|
|
53
|
+
.default('config', defaultWebpackConfig);
|
|
42
54
|
},
|
|
55
|
+
path: resolve(__dirname, 'webpack', 'pilet.js'),
|
|
43
56
|
};
|
|
@@ -6,7 +6,7 @@ export class HotModuleServerPlugin implements WebpackPluginInstance {
|
|
|
6
6
|
apply(compiler: Compiler) {
|
|
7
7
|
const express = require('express');
|
|
8
8
|
const app = express();
|
|
9
|
-
app.use(require('webpack-hot-middleware')(compiler));
|
|
9
|
+
app.use(require('../../../src/webpack-hot-middleware/middleware')(compiler));
|
|
10
10
|
app.listen(this.hmrPort, () => {});
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { HotModuleReplacementPlugin, Configuration } from 'webpack';
|
|
2
|
+
import { HotModuleServerPlugin } from './HotModuleServerPlugin';
|
|
3
|
+
|
|
4
|
+
export interface HmrWebpackPluginOptions {
|
|
5
|
+
port: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getHmrEntry(hmrPort: number): [] | [string] {
|
|
9
|
+
return hmrPort
|
|
10
|
+
? [
|
|
11
|
+
`piral-cli-webpack5/src/webpack-hot-middleware/client?path=http://localhost:${hmrPort}/__webpack_hmr&reload=true`,
|
|
12
|
+
]
|
|
13
|
+
: [];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const hmrWebpackConfigEnhancer = (options: HmrWebpackPluginOptions) => (compilerOptions: Configuration) => {
|
|
17
|
+
const { port } = options;
|
|
18
|
+
|
|
19
|
+
if (port) {
|
|
20
|
+
if (Array.isArray(compilerOptions.entry)) {
|
|
21
|
+
compilerOptions.entry.unshift(...getHmrEntry(port));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const newPlugins = [new HotModuleReplacementPlugin(), new HotModuleServerPlugin(port)];
|
|
25
|
+
|
|
26
|
+
if (!compilerOptions.plugins) {
|
|
27
|
+
compilerOptions.plugins = newPlugins;
|
|
28
|
+
} else if (Array.isArray(compilerOptions.plugins)) {
|
|
29
|
+
compilerOptions.plugins.push(...newPlugins);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return compilerOptions;
|
|
34
|
+
};
|
|
@@ -18,15 +18,15 @@ export function isLocal(path: string) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
export function extractParts(content:
|
|
22
|
-
const sheets = content('link[href]')
|
|
23
|
-
.filter((_, e) => isLocal(e.attribs.href))
|
|
21
|
+
export function extractParts(content: cheerio.Root) {
|
|
22
|
+
const sheets = content('link[href][rel=stylesheet]')
|
|
23
|
+
.filter((_, e: cheerio.TagElement) => isLocal(e.attribs.href))
|
|
24
24
|
.remove()
|
|
25
|
-
.toArray()
|
|
25
|
+
.toArray() as Array<cheerio.TagElement>;
|
|
26
26
|
const scripts = content('script[src]')
|
|
27
|
-
.filter((_, e) => isLocal(e.attribs.src))
|
|
27
|
+
.filter((_, e: cheerio.TagElement) => isLocal(e.attribs.src))
|
|
28
28
|
.remove()
|
|
29
|
-
.toArray()
|
|
29
|
+
.toArray() as Array<cheerio.TagElement>;
|
|
30
30
|
const files: Array<string> = [];
|
|
31
31
|
|
|
32
32
|
for (const sheet of sheets) {
|
|
@@ -61,7 +61,7 @@ export function replaceEntries(existingEntries: Array<string>, oldEntry: string,
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function setEntries(config: Configuration, template: string, entries: [string, ...string
|
|
64
|
+
export function setEntries(config: Configuration, template: string, entries: [string, ...Array<string>]) {
|
|
65
65
|
if (typeof config.entry === 'string') {
|
|
66
66
|
config.entry = entries;
|
|
67
67
|
} else if (Array.isArray(config.entry)) {
|