@pinnacle0/webpack-util 0.3.16-beta1 → 0.3.16-beta2
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 +1 -1
- package/src/CanadyarnRunner.d.ts +14 -0
- package/src/CanadyarnRunner.js +38 -0
- package/src/CanadyarnRunner.js.map +1 -0
- package/src/CodeStyleChecker.d.ts +10 -0
- package/src/CodeStyleChecker.js +44 -0
- package/src/CodeStyleChecker.js.map +1 -0
- package/src/Constant.d.ts +21 -0
- package/src/{Constant.ts → Constant.js} +5 -1
- package/src/Constant.js.map +1 -0
- package/src/CoreUtil.d.ts +11 -0
- package/src/CoreUtil.js +26 -0
- package/src/CoreUtil.js.map +1 -0
- package/src/ProjectStructureChecker.d.ts +18 -0
- package/src/ProjectStructureChecker.js +113 -0
- package/src/ProjectStructureChecker.js.map +1 -0
- package/src/TestRunner.d.ts +8 -0
- package/src/TestRunner.js +30 -0
- package/src/TestRunner.js.map +1 -0
- package/src/WebpackBuilder.d.ts +38 -0
- package/src/{WebpackBuilder.ts → WebpackBuilder.js} +49 -69
- package/src/WebpackBuilder.js.map +1 -0
- package/src/WebpackConfigGenerator/ConfigEntryDescriptorsFactory.d.ts +13 -0
- package/src/WebpackConfigGenerator/{ConfigEntryDescriptorsFactory.ts → ConfigEntryDescriptorsFactory.js} +29 -36
- package/src/WebpackConfigGenerator/ConfigEntryDescriptorsFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.d.ts +9 -0
- package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.js +20 -0
- package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/css.plugin.d.ts +16 -0
- package/src/WebpackConfigGenerator/Plugin/css.plugin.js +33 -0
- package/src/WebpackConfigGenerator/Plugin/css.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/esbuild.plugin.d.ts +2 -0
- package/src/WebpackConfigGenerator/Plugin/esbuild.plugin.js +14 -0
- package/src/WebpackConfigGenerator/Plugin/esbuild.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/html.plugin.d.ts +16 -0
- package/src/WebpackConfigGenerator/Plugin/html.plugin.js +48 -0
- package/src/WebpackConfigGenerator/Plugin/html.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/index.d.ts +29 -0
- package/src/WebpackConfigGenerator/Plugin/index.js +34 -0
- package/src/WebpackConfigGenerator/Plugin/index.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/moment.plugin.d.ts +10 -0
- package/src/WebpackConfigGenerator/Plugin/{moment.plugin.ts → moment.plugin.js} +12 -5
- package/src/WebpackConfigGenerator/Plugin/moment.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.d.ts +4 -0
- package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.js +28 -0
- package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/ts.plugin.d.ts +16 -0
- package/src/WebpackConfigGenerator/Plugin/ts.plugin.js +31 -0
- package/src/WebpackConfigGenerator/Plugin/ts.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Plugin/webpack.plugin.d.ts +14 -0
- package/src/WebpackConfigGenerator/Plugin/webpack.plugin.js +24 -0
- package/src/WebpackConfigGenerator/Plugin/webpack.plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/RegExpUtil.d.ts +4 -0
- package/src/WebpackConfigGenerator/Rule/{RegExpUtil.ts → RegExpUtil.js} +14 -8
- package/src/WebpackConfigGenerator/Rule/RegExpUtil.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.d.ts +13 -0
- package/src/WebpackConfigGenerator/Rule/{core-fe-hmr-babel-plugin.ts → core-fe-hmr-babel-plugin.js} +9 -43
- package/src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/image.rule.d.ts +9 -0
- package/src/WebpackConfigGenerator/Rule/{image.rule.ts → image.rule.js} +8 -5
- package/src/WebpackConfigGenerator/Rule/image.rule.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/index.d.ts +13 -0
- package/src/WebpackConfigGenerator/Rule/index.js +18 -0
- package/src/WebpackConfigGenerator/Rule/index.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/other.rule.d.ts +12 -0
- package/src/WebpackConfigGenerator/Rule/other.rule.js +22 -0
- package/src/WebpackConfigGenerator/Rule/other.rule.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/stylesheet.rule.d.ts +17 -0
- package/src/WebpackConfigGenerator/Rule/{stylesheet.rule.ts → stylesheet.rule.js} +30 -34
- package/src/WebpackConfigGenerator/Rule/stylesheet.rule.js.map +1 -0
- package/src/WebpackConfigGenerator/Rule/ts.rule.d.ts +19 -0
- package/src/WebpackConfigGenerator/Rule/{ts.rule.ts → ts.rule.js} +16 -19
- package/src/WebpackConfigGenerator/Rule/ts.rule.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackConfigSerializationUtil.d.ts +10 -0
- package/src/WebpackConfigGenerator/{WebpackConfigSerializationUtil.ts → WebpackConfigSerializationUtil.js} +22 -23
- package/src/WebpackConfigGenerator/WebpackConfigSerializationUtil.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackEntryFactory.d.ts +9 -0
- package/src/WebpackConfigGenerator/WebpackEntryFactory.js +14 -0
- package/src/WebpackConfigGenerator/WebpackEntryFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.d.ts +11 -0
- package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.js +16 -0
- package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackResolveAliasFactory.d.ts +11 -0
- package/src/WebpackConfigGenerator/{WebpackResolveAliasFactory.ts → WebpackResolveAliasFactory.js} +13 -16
- package/src/WebpackConfigGenerator/WebpackResolveAliasFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.d.ts +7 -0
- package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.js +16 -0
- package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/WebpackResolveModulesFactory.d.ts +7 -0
- package/src/WebpackConfigGenerator/{WebpackResolveModulesFactory.ts → WebpackResolveModulesFactory.js} +7 -9
- package/src/WebpackConfigGenerator/WebpackResolveModulesFactory.js.map +1 -0
- package/src/WebpackConfigGenerator/index.d.ts +31 -0
- package/src/WebpackConfigGenerator/index.js +191 -0
- package/src/WebpackConfigGenerator/index.js.map +1 -0
- package/src/WebpackServerStarter.d.ts +28 -0
- package/src/WebpackServerStarter.js +111 -0
- package/src/WebpackServerStarter.js.map +1 -0
- package/src/index.d.ts +10 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
- package/src/{type.ts → type.d.ts} +4 -8
- package/src/type.js +3 -0
- package/src/type.js.map +1 -0
- package/config/jest.config.ts +0 -35
- package/config/tsconfig.script.json +0 -11
- package/config/tsconfig.src.json +0 -12
- package/config/tsconfig.test.json +0 -12
- package/script/build.ts +0 -65
- package/script/format.ts +0 -7
- package/src/CanadyarnRunner.ts +0 -35
- package/src/CodeStyleChecker.ts +0 -44
- package/src/CoreUtil.ts +0 -24
- package/src/ProjectStructureChecker.ts +0 -119
- package/src/TestRunner.ts +0 -28
- package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.ts +0 -24
- package/src/WebpackConfigGenerator/Plugin/css.plugin.ts +0 -31
- package/src/WebpackConfigGenerator/Plugin/esbuild.plugin.ts +0 -11
- package/src/WebpackConfigGenerator/Plugin/html.plugin.ts +0 -47
- package/src/WebpackConfigGenerator/Plugin/index.ts +0 -35
- package/src/WebpackConfigGenerator/Plugin/script-tag-crossorigin-plugin.ts +0 -22
- package/src/WebpackConfigGenerator/Plugin/ts.plugin.ts +0 -29
- package/src/WebpackConfigGenerator/Plugin/webpack.plugin.ts +0 -21
- package/src/WebpackConfigGenerator/Rule/index.ts +0 -17
- package/src/WebpackConfigGenerator/Rule/other.rule.ts +0 -23
- package/src/WebpackConfigGenerator/WebpackEntryFactory.ts +0 -22
- package/src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.ts +0 -22
- package/src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.ts +0 -19
- package/src/WebpackConfigGenerator/index.ts +0 -213
- package/src/WebpackServerStarter.ts +0 -138
- package/src/index.ts +0 -9
- package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/__snapshots__/shouldIgnore.test.ts.snap +0 -21
- package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/__snapshots__/shouldTransform.test.ts.snap +0 -53
- package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/shouldIgnore.test.ts +0 -36
- package/test/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin/shouldTransform.test.ts +0 -72
- package/test/WebpackConfigGenerator/plugin/fixture/script.js +0 -2
- package/test/WebpackConfigGenerator/plugin/fixture/script1.js +0 -1
- package/test/WebpackConfigGenerator/plugin/script-tag-crossorigin-plugin.test.ts +0 -58
- package/test/test-project/package.json +0 -5
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type * as babel from "@babel/core";
|
|
2
|
+
interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" | "filename"> {
|
|
3
|
+
hasInjectedDeclineWebpackHMRNode: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Injects `if (module.hot) module.hot.decline()` code snippet in files that contains "core-fe" Module classes.
|
|
7
|
+
*
|
|
8
|
+
* This tells webpack HMR to force refresh the browser when a file containing "core-fe" Module classes is changed,
|
|
9
|
+
* otherwise react loses refrence of the MainComponent created by `ModuleProxy` in "core-fe"
|
|
10
|
+
* and throws a runtime error during development (which is bad for developer experience).
|
|
11
|
+
*/
|
|
12
|
+
export default function ({ types: t }: typeof babel): babel.PluginObj<State>;
|
|
13
|
+
export {};
|
package/src/WebpackConfigGenerator/Rule/{core-fe-hmr-babel-plugin.ts → core-fe-hmr-babel-plugin.js}
RENAMED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" | "filename"> {
|
|
4
|
-
hasInjectedDeclineWebpackHMRNode: boolean;
|
|
5
|
-
}
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
3
|
/**
|
|
8
4
|
* Injects `if (module.hot) module.hot.decline()` code snippet in files that contains "core-fe" Module classes.
|
|
9
5
|
*
|
|
@@ -11,68 +7,39 @@ interface State extends Pick<babel.PluginPass, "file" | "key" | "opts" | "cwd" |
|
|
|
11
7
|
* otherwise react loses refrence of the MainComponent created by `ModuleProxy` in "core-fe"
|
|
12
8
|
* and throws a runtime error during development (which is bad for developer experience).
|
|
13
9
|
*/
|
|
14
|
-
|
|
10
|
+
function default_1({ types: t }) {
|
|
15
11
|
return {
|
|
16
12
|
visitor: {
|
|
17
13
|
ImportDeclaration(path, state) {
|
|
18
14
|
if (state.hasInjectedDeclineWebpackHMRNode) {
|
|
19
15
|
return;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
|
-
const {
|
|
23
|
-
node: {
|
|
24
|
-
source: {value: importSource},
|
|
25
|
-
specifiers: importSpecifiers,
|
|
26
|
-
},
|
|
27
|
-
} = path;
|
|
28
|
-
|
|
17
|
+
const { node: { source: { value: importSource }, specifiers: importSpecifiers, }, } = path;
|
|
29
18
|
if (importSource !== "core-fe") {
|
|
30
19
|
return;
|
|
31
20
|
}
|
|
32
|
-
|
|
33
21
|
if (!hasImportSpecifierOfIdentifierModule(t, importSpecifiers)) {
|
|
34
22
|
return;
|
|
35
23
|
}
|
|
36
|
-
|
|
37
24
|
// We now know the TS/JS file has included `Module`, inject the code snippet
|
|
38
|
-
const programPath = path.findParent(parentPath => t.isProgram(parentPath.node))
|
|
39
|
-
|
|
25
|
+
const programPath = path.findParent(parentPath => t.isProgram(parentPath.node));
|
|
40
26
|
// prettier-ignore
|
|
41
|
-
const declineWebpackHMRNode = t.ifStatement(
|
|
42
|
-
t.memberExpression(
|
|
43
|
-
t.identifier("module"),
|
|
44
|
-
t.identifier("hot")
|
|
45
|
-
),
|
|
46
|
-
t.expressionStatement(
|
|
47
|
-
t.callExpression(
|
|
48
|
-
t.memberExpression(
|
|
49
|
-
t.memberExpression(
|
|
50
|
-
t.identifier("module"),
|
|
51
|
-
t.identifier("hot"),
|
|
52
|
-
),
|
|
53
|
-
t.identifier("decline"),
|
|
54
|
-
),
|
|
55
|
-
[],
|
|
56
|
-
),
|
|
57
|
-
),
|
|
58
|
-
);
|
|
59
|
-
|
|
27
|
+
const declineWebpackHMRNode = t.ifStatement(t.memberExpression(t.identifier("module"), t.identifier("hot")), t.expressionStatement(t.callExpression(t.memberExpression(t.memberExpression(t.identifier("module"), t.identifier("hot")), t.identifier("decline")), [])));
|
|
60
28
|
// Append `if (module.hot) module.hot.decline()` to end of program body
|
|
61
29
|
programPath.pushContainer("body", declineWebpackHMRNode);
|
|
62
|
-
|
|
63
30
|
// We only need to inject the code snippet once per file, mark as injected
|
|
64
31
|
state.hasInjectedDeclineWebpackHMRNode = true;
|
|
65
32
|
},
|
|
66
33
|
},
|
|
67
34
|
};
|
|
68
35
|
}
|
|
69
|
-
|
|
36
|
+
exports.default = default_1;
|
|
70
37
|
/**
|
|
71
38
|
* @param t `babel.types`
|
|
72
39
|
* @param importSpecifiers The "specifier" property of a `babel.types.ImportDeclaration` node
|
|
73
40
|
* @returns true if the import declaration includes the identifier `Module`
|
|
74
41
|
*/
|
|
75
|
-
function hasImportSpecifierOfIdentifierModule(t
|
|
42
|
+
function hasImportSpecifierOfIdentifierModule(t, importSpecifiers) {
|
|
76
43
|
const specifier = importSpecifiers.find(specifier => {
|
|
77
44
|
// Check if it is one of:
|
|
78
45
|
// -> `import { <IMPORT_SPECIFIER_NODE> } from "core-fe";`
|
|
@@ -81,7 +48,6 @@ function hasImportSpecifierOfIdentifierModule(t: typeof babel.types, importSpeci
|
|
|
81
48
|
const importedSpecifier = specifier.imported;
|
|
82
49
|
return t.isIdentifier(importedSpecifier) && importedSpecifier.name === "Module";
|
|
83
50
|
}
|
|
84
|
-
|
|
85
51
|
// Check if it is:
|
|
86
52
|
// -> `import * as <IMPORT_NAMESPACE_SPECIFIER_NODE> from "core-fe";`
|
|
87
53
|
if (t.isImportNamespaceSpecifier(specifier)) {
|
|
@@ -89,8 +55,8 @@ function hasImportSpecifierOfIdentifierModule(t: typeof babel.types, importSpeci
|
|
|
89
55
|
// Maybe enforce "core-fe" should not be imported with a namespace with an ESLint rule?
|
|
90
56
|
return true;
|
|
91
57
|
}
|
|
92
|
-
|
|
93
58
|
return false;
|
|
94
59
|
});
|
|
95
60
|
return specifier !== undefined;
|
|
96
61
|
}
|
|
62
|
+
//# sourceMappingURL=core-fe-hmr-babel-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-fe-hmr-babel-plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/core-fe-hmr-babel-plugin.ts"],"names":[],"mappings":";;AAMA;;;;;;GAMG;AACH,mBAAyB,EAAC,KAAK,EAAE,CAAC,EAAe;IAC7C,OAAO;QACH,OAAO,EAAE;YACL,iBAAiB,CAAC,IAAI,EAAE,KAAK;gBACzB,IAAI,KAAK,CAAC,gCAAgC,EAAE;oBACxC,OAAO;iBACV;gBAED,MAAM,EACF,IAAI,EAAE,EACF,MAAM,EAAE,EAAC,KAAK,EAAE,YAAY,EAAC,EAC7B,UAAU,EAAE,gBAAgB,GAC/B,GACJ,GAAG,IAAI,CAAC;gBAET,IAAI,YAAY,KAAK,SAAS,EAAE;oBAC5B,OAAO;iBACV;gBAED,IAAI,CAAC,oCAAoC,CAAC,CAAC,EAAE,gBAAgB,CAAC,EAAE;oBAC5D,OAAO;iBACV;gBAED,4EAA4E;gBAC5E,MAAM,WAAW,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAyC,CAAC;gBAExH,kBAAkB;gBAClB,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CACvC,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EACtB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CACtB,EACD,CAAC,CAAC,mBAAmB,CACjB,CAAC,CAAC,cAAc,CACZ,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,gBAAgB,CACd,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,EACtB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CACtB,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAC1B,EACD,EAAE,CACL,CACJ,CACJ,CAAC;gBAEF,uEAAuE;gBACvE,WAAW,CAAC,aAAa,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;gBAEzD,0EAA0E;gBAC1E,KAAK,CAAC,gCAAgC,GAAG,IAAI,CAAC;YAClD,CAAC;SACJ;KACJ,CAAC;AACN,CAAC;AAtDD,4BAsDC;AAED;;;;GAIG;AACH,SAAS,oCAAoC,CAAC,CAAqB,EAAE,gBAA6D;IAC9H,MAAM,SAAS,GAAG,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;QAChD,yBAAyB;QACzB,0DAA0D;QAC1D,gFAAgF;QAChF,IAAI,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE;YAChC,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAAC;YAC7C,OAAO,CAAC,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,IAAI,KAAK,QAAQ,CAAC;SACnF;QAED,kBAAkB;QAClB,qEAAqE;QACrE,IAAI,CAAC,CAAC,0BAA0B,CAAC,SAAS,CAAC,EAAE;YACzC,oFAAoF;YACpF,uFAAuF;YACvF,OAAO,IAAI,CAAC;SACf;QAED,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,KAAK,SAAS,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
/**
|
|
3
|
+
* Handles dependency requests to image assets (".png", ".jpeg", ".jpg", ".gif", ".svg")
|
|
4
|
+
* by inlining as images as DataURL,
|
|
5
|
+
* or emitting as separate files if file size is too large.
|
|
6
|
+
*
|
|
7
|
+
* @see https://webpack.js.org/guides/asset-modules/
|
|
8
|
+
*/
|
|
9
|
+
export declare function imageRule(): webpack.RuleSetRule;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageRule = void 0;
|
|
4
|
+
const RegExpUtil_1 = require("./RegExpUtil");
|
|
4
5
|
/**
|
|
5
6
|
* Handles dependency requests to image assets (".png", ".jpeg", ".jpg", ".gif", ".svg")
|
|
6
7
|
* by inlining as images as DataURL,
|
|
@@ -8,9 +9,9 @@ import {RegExpUtil} from "./RegExpUtil";
|
|
|
8
9
|
*
|
|
9
10
|
* @see https://webpack.js.org/guides/asset-modules/
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
function imageRule() {
|
|
12
13
|
return {
|
|
13
|
-
test: RegExpUtil.fileExtension(".png", ".jpeg", ".jpg", ".gif", ".svg"),
|
|
14
|
+
test: RegExpUtil_1.RegExpUtil.fileExtension(".png", ".jpeg", ".jpg", ".gif", ".svg"),
|
|
14
15
|
type: "asset",
|
|
15
16
|
generator: {
|
|
16
17
|
filename: "static/img/[name].[hash:8][ext][query]",
|
|
@@ -22,3 +23,5 @@ export function imageRule(): webpack.RuleSetRule {
|
|
|
22
23
|
},
|
|
23
24
|
};
|
|
24
25
|
}
|
|
26
|
+
exports.imageRule = imageRule;
|
|
27
|
+
//# sourceMappingURL=image.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/image.rule.ts"],"names":[],"mappings":";;;AACA,6CAAwC;AAExC;;;;;;GAMG;AACH,SAAgB,SAAS;IACrB,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;QACvE,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACP,QAAQ,EAAE,wCAAwC;SACrD;QACD,MAAM,EAAE;YACJ,gBAAgB,EAAE;gBACd,OAAO,EAAE,IAAI;aAChB;SACJ;KACJ,CAAC;AACN,CAAC;AAbD,8BAaC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { imageRule } from "./image.rule";
|
|
2
|
+
import { otherRule } from "./other.rule";
|
|
3
|
+
import { stylesheetRule } from "./stylesheet.rule";
|
|
4
|
+
import { tsRule } from "./ts.rule";
|
|
5
|
+
/**
|
|
6
|
+
* Static factories to create `webpack.config#modules.rules` items.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Rule {
|
|
9
|
+
static readonly image: typeof imageRule;
|
|
10
|
+
static readonly other: typeof otherRule;
|
|
11
|
+
static readonly ts: typeof tsRule;
|
|
12
|
+
static readonly stylesheet: typeof stylesheetRule;
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Rule = void 0;
|
|
4
|
+
const image_rule_1 = require("./image.rule");
|
|
5
|
+
const other_rule_1 = require("./other.rule");
|
|
6
|
+
const stylesheet_rule_1 = require("./stylesheet.rule");
|
|
7
|
+
const ts_rule_1 = require("./ts.rule");
|
|
8
|
+
/**
|
|
9
|
+
* Static factories to create `webpack.config#modules.rules` items.
|
|
10
|
+
*/
|
|
11
|
+
class Rule {
|
|
12
|
+
}
|
|
13
|
+
exports.Rule = Rule;
|
|
14
|
+
Rule.image = image_rule_1.imageRule;
|
|
15
|
+
Rule.other = other_rule_1.otherRule;
|
|
16
|
+
Rule.ts = ts_rule_1.tsRule;
|
|
17
|
+
Rule.stylesheet = stylesheet_rule_1.stylesheetRule;
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AACvC,6CAAuC;AACvC,uDAAiD;AACjD,uCAAiC;AAEjC;;GAEG;AACH,MAAa,IAAI;;AAAjB,oBAQC;AAPmB,UAAK,GAAG,sBAAS,CAAC;AAElB,UAAK,GAAG,sBAAS,CAAC;AAElB,OAAE,GAAG,gBAAM,CAAC;AAEZ,eAAU,GAAG,gCAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
interface OtherRuleDeps {
|
|
3
|
+
extraExtensionsForOtherRule: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Handles dependency requests to file assets
|
|
7
|
+
* by emitting as separate files.
|
|
8
|
+
*
|
|
9
|
+
* @see https://webpack.js.org/guides/asset-modules/
|
|
10
|
+
*/
|
|
11
|
+
export declare function otherRule({ extraExtensionsForOtherRule }: OtherRuleDeps): webpack.RuleSetRule;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.otherRule = void 0;
|
|
4
|
+
const Constant_1 = require("../../Constant");
|
|
5
|
+
const RegExpUtil_1 = require("./RegExpUtil");
|
|
6
|
+
/**
|
|
7
|
+
* Handles dependency requests to file assets
|
|
8
|
+
* by emitting as separate files.
|
|
9
|
+
*
|
|
10
|
+
* @see https://webpack.js.org/guides/asset-modules/
|
|
11
|
+
*/
|
|
12
|
+
function otherRule({ extraExtensionsForOtherRule }) {
|
|
13
|
+
return {
|
|
14
|
+
test: RegExpUtil_1.RegExpUtil.fileExtension(".ico", ...Constant_1.Constant.mediaExtensions, ...Constant_1.Constant.fontExtensions, ...extraExtensionsForOtherRule),
|
|
15
|
+
type: "asset",
|
|
16
|
+
generator: {
|
|
17
|
+
filename: "static/other/[name].[hash:8][ext][query]",
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.otherRule = otherRule;
|
|
22
|
+
//# sourceMappingURL=other.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"other.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/other.rule.ts"],"names":[],"mappings":";;;AACA,6CAAwC;AACxC,6CAAwC;AAMxC;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,EAAC,2BAA2B,EAAgB;IAClE,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,mBAAQ,CAAC,eAAe,EAAE,GAAG,mBAAQ,CAAC,cAAc,EAAE,GAAG,2BAA2B,CAAC;QAC/H,IAAI,EAAE,OAAO;QACb,SAAS,EAAE;YACP,QAAQ,EAAE,0CAA0C;SACvD;KACJ,CAAC;AACN,CAAC;AARD,8BAQC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
interface StylesheetRuleDeps {
|
|
3
|
+
minimize: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Handles dependency requests to stylesheet assets (".css", ".less")
|
|
7
|
+
* with `minimize: true` by `lessc` -> transform to js module -> inject to DOM as <style> tag,
|
|
8
|
+
* or with `minimize: false` by `lessc` -> `autoprefixer` with `postcss` -> transform to js module -> extract to stylesheet
|
|
9
|
+
*
|
|
10
|
+
* @see https://webpack.js.org/loaders/css-loader/
|
|
11
|
+
* @see https://webpack.js.org/loaders/less-loader/
|
|
12
|
+
* @see https://webpack.js.org/plugins/mini-css-extract-plugin/
|
|
13
|
+
* @see https://webpack.js.org/loaders/postcss-loader/
|
|
14
|
+
* @see https://webpack.js.org/loaders/style-loader/
|
|
15
|
+
*/
|
|
16
|
+
export declare function stylesheetRule({ minimize }: StylesheetRuleDeps): webpack.RuleSetRule;
|
|
17
|
+
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function cssLoader(importLoaders
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stylesheetRule = void 0;
|
|
7
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
8
|
+
const RegExpUtil_1 = require("./RegExpUtil");
|
|
9
|
+
function cssLoader(importLoaders) {
|
|
10
10
|
return {
|
|
11
11
|
loader: require.resolve("css-loader"),
|
|
12
12
|
options: {
|
|
@@ -14,8 +14,7 @@ function cssLoader(importLoaders: number): webpack.RuleSetUseItem {
|
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
function lessLoader(): webpack.RuleSetUseItem {
|
|
17
|
+
function lessLoader() {
|
|
19
18
|
return {
|
|
20
19
|
loader: require.resolve("less-loader"),
|
|
21
20
|
options: {
|
|
@@ -25,14 +24,12 @@ function lessLoader(): webpack.RuleSetUseItem {
|
|
|
25
24
|
},
|
|
26
25
|
};
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
function miniCssExtractPluginLoader(): webpack.RuleSetUseItem {
|
|
27
|
+
function miniCssExtractPluginLoader() {
|
|
30
28
|
return {
|
|
31
|
-
loader: require.resolve(
|
|
29
|
+
loader: require.resolve(mini_css_extract_plugin_1.default.loader),
|
|
32
30
|
};
|
|
33
31
|
}
|
|
34
|
-
|
|
35
|
-
function postcssLoader(): webpack.RuleSetUseItem {
|
|
32
|
+
function postcssLoader() {
|
|
36
33
|
return {
|
|
37
34
|
loader: require.resolve("postcss-loader"),
|
|
38
35
|
options: {
|
|
@@ -45,13 +42,11 @@ function postcssLoader(): webpack.RuleSetUseItem {
|
|
|
45
42
|
},
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
function styleLoader(): webpack.RuleSetUseItem {
|
|
45
|
+
function styleLoader() {
|
|
50
46
|
return {
|
|
51
47
|
loader: require.resolve("style-loader"),
|
|
52
48
|
};
|
|
53
49
|
}
|
|
54
|
-
|
|
55
50
|
/**
|
|
56
51
|
* Handles dependency requests to stylesheet assets (".css", ".less")
|
|
57
52
|
* with `minimize: true` by `lessc` -> transform to js module -> inject to DOM as <style> tag,
|
|
@@ -63,24 +58,23 @@ function styleLoader(): webpack.RuleSetUseItem {
|
|
|
63
58
|
* @see https://webpack.js.org/loaders/postcss-loader/
|
|
64
59
|
* @see https://webpack.js.org/loaders/style-loader/
|
|
65
60
|
*/
|
|
66
|
-
|
|
67
|
-
const use
|
|
61
|
+
function stylesheetRule({ minimize }) {
|
|
62
|
+
const use = minimize
|
|
68
63
|
? [
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
miniCssExtractPluginLoader(),
|
|
65
|
+
cssLoader(2),
|
|
66
|
+
postcssLoader(),
|
|
67
|
+
lessLoader(),
|
|
68
|
+
// prettier-format-preserve
|
|
69
|
+
]
|
|
75
70
|
: [
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
71
|
+
styleLoader(),
|
|
72
|
+
cssLoader(1),
|
|
73
|
+
lessLoader(),
|
|
74
|
+
// prettier-format-preserve
|
|
75
|
+
];
|
|
82
76
|
return {
|
|
83
|
-
test: RegExpUtil.fileExtension(".css", ".less"),
|
|
77
|
+
test: RegExpUtil_1.RegExpUtil.fileExtension(".css", ".less"),
|
|
84
78
|
use,
|
|
85
79
|
// Declare all css/less imports as side effects (not to be considered
|
|
86
80
|
// as dead code), regardless of the containing package claims to be
|
|
@@ -90,3 +84,5 @@ export function stylesheetRule({minimize}: StylesheetRuleDeps): webpack.RuleSetR
|
|
|
90
84
|
sideEffects: true,
|
|
91
85
|
};
|
|
92
86
|
}
|
|
87
|
+
exports.stylesheetRule = stylesheetRule;
|
|
88
|
+
//# sourceMappingURL=stylesheet.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stylesheet.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/stylesheet.rule.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA2D;AAE3D,6CAAwC;AAMxC,SAAS,SAAS,CAAC,aAAqB;IACpC,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE;YACL,aAAa;SAChB;KACJ,CAAC;AACN,CAAC;AAED,SAAS,UAAU;IACf,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC;QACtC,OAAO,EAAE;YACL,WAAW,EAAE;gBACT,iBAAiB,EAAE,IAAI;aAC1B;SACJ;KACJ,CAAC;AACN,CAAC;AAED,SAAS,0BAA0B;IAC/B,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,iCAAoB,CAAC,MAAM,CAAC;KACvD,CAAC;AACN,CAAC;AAED,SAAS,aAAa;IAClB,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC;QACzC,OAAO,EAAE;YACL,cAAc,EAAE;gBACZ,OAAO,EAAE;oBACL,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;oBACjC,2BAA2B;iBAC9B;aACJ;SACJ;KACJ,CAAC;AACN,CAAC;AAED,SAAS,WAAW;IAChB,OAAO;QACH,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;KAC1C,CAAC;AACN,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAC,EAAC,QAAQ,EAAqB;IACzD,MAAM,GAAG,GAA6B,QAAQ;QAC1C,CAAC,CAAC;YACI,0BAA0B,EAAE;YAC5B,SAAS,CAAC,CAAC,CAAC;YACZ,aAAa,EAAE;YACf,UAAU,EAAE;YACZ,2BAA2B;SAC9B;QACH,CAAC,CAAC;YACI,WAAW,EAAE;YACb,SAAS,CAAC,CAAC,CAAC;YACZ,UAAU,EAAE;YACZ,2BAA2B;SAC9B,CAAC;IAER,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC;QAC/C,GAAG;QACH,qEAAqE;QACrE,mEAAmE;QACnE,uDAAuD;QACvD,sEAAsE;QACtE,sDAAsD;QACtD,WAAW,EAAE,IAAI;KACpB,CAAC;AACN,CAAC;AA1BD,wCA0BC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
interface Deps {
|
|
3
|
+
tsconfigFilepath: string;
|
|
4
|
+
transpileOnly: boolean;
|
|
5
|
+
fastRefresh: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Handles dependency requests to typescript files
|
|
9
|
+
* by compiling with `tsc`.
|
|
10
|
+
*
|
|
11
|
+
* To enable react fast refresh, set `withReactFastRefreshBabelPlugin` to true,
|
|
12
|
+
* this requires "@pmmmwh/react-refresh-webpack-plugin" webpack plugin to work,
|
|
13
|
+
* and should not be used in production.
|
|
14
|
+
*
|
|
15
|
+
* @see https://github.com/TypeStrong/ts-loader
|
|
16
|
+
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin
|
|
17
|
+
*/
|
|
18
|
+
export declare function tsRule({ tsconfigFilepath, transpileOnly, fastRefresh }: Deps): webpack.RuleSetRule;
|
|
19
|
+
export {};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.tsRule = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const RegExpUtil_1 = require("./RegExpUtil");
|
|
11
9
|
/**
|
|
12
10
|
* Handles dependency requests to typescript files
|
|
13
11
|
* by compiling with `tsc`.
|
|
@@ -19,15 +17,14 @@ interface Deps {
|
|
|
19
17
|
* @see https://github.com/TypeStrong/ts-loader
|
|
20
18
|
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin
|
|
21
19
|
*/
|
|
22
|
-
|
|
23
|
-
const babelLoader
|
|
20
|
+
function tsRule({ tsconfigFilepath, transpileOnly, fastRefresh }) {
|
|
21
|
+
const babelLoader = {
|
|
24
22
|
loader: require.resolve("babel-loader"),
|
|
25
23
|
options: {
|
|
26
|
-
plugins: [require.resolve(
|
|
24
|
+
plugins: [require.resolve(path_1.default.join(__dirname, "./core-fe-hmr-babel-plugin")), require.resolve("react-refresh/babel")],
|
|
27
25
|
},
|
|
28
26
|
};
|
|
29
|
-
|
|
30
|
-
const tsLoader: webpack.RuleSetUseItem = {
|
|
27
|
+
const tsLoader = {
|
|
31
28
|
loader: require.resolve("ts-loader"),
|
|
32
29
|
options: {
|
|
33
30
|
colors: false,
|
|
@@ -40,8 +37,7 @@ export function tsRule({tsconfigFilepath, transpileOnly, fastRefresh}: Deps): we
|
|
|
40
37
|
transpileOnly,
|
|
41
38
|
},
|
|
42
39
|
};
|
|
43
|
-
|
|
44
|
-
const swcLoader: webpack.RuleSetUseItem = {
|
|
40
|
+
const swcLoader = {
|
|
45
41
|
loader: require.resolve("swc-loader"),
|
|
46
42
|
options: {
|
|
47
43
|
jsc: {
|
|
@@ -60,9 +56,10 @@ export function tsRule({tsconfigFilepath, transpileOnly, fastRefresh}: Deps): we
|
|
|
60
56
|
},
|
|
61
57
|
},
|
|
62
58
|
};
|
|
63
|
-
|
|
64
59
|
return {
|
|
65
|
-
test: RegExpUtil.fileExtension(".ts", ".tsx"),
|
|
60
|
+
test: RegExpUtil_1.RegExpUtil.fileExtension(".ts", ".tsx"),
|
|
66
61
|
use: fastRefresh ? [babelLoader, tsLoader] : [swcLoader],
|
|
67
62
|
};
|
|
68
63
|
}
|
|
64
|
+
exports.tsRule = tsRule;
|
|
65
|
+
//# sourceMappingURL=ts.rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/ts.rule.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,6CAAwC;AAQxC;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,EAAC,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAO;IACvE,MAAM,WAAW,GAA2B;QACxC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC;QACvC,OAAO,EAAE;YACL,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,4BAA4B,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;SACzH;KACJ,CAAC;IAEF,MAAM,QAAQ,GAA2B;QACrC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;QACpC,OAAO,EAAE;YACL,MAAM,EAAE,KAAK;YACb,UAAU,EAAE,gBAAgB;YAC5B,eAAe,EAAE;gBACb,MAAM,EAAE,QAAQ;gBAChB,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE,KAAK;aAChB;YACD,aAAa;SAChB;KACJ,CAAC;IAEF,MAAM,SAAS,GAA2B;QACtC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC;QACrC,OAAO,EAAE;YACL,GAAG,EAAE;gBACD,MAAM,EAAE,KAAK;gBACb,MAAM,EAAE;oBACJ,MAAM,EAAE,YAAY;oBACpB,UAAU,EAAE,IAAI;iBACnB;gBACD,SAAS,EAAE;oBACP,KAAK,EAAE;wBACH,OAAO,EAAE,SAAS;qBACrB;oBACD,eAAe,EAAE,IAAI;oBACrB,iBAAiB,EAAE,IAAI;iBAC1B;aACJ;SACJ;KACJ,CAAC;IAEF,OAAO;QACH,IAAI,EAAE,uBAAU,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC;QAC7C,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;KAC3D,CAAC;AACN,CAAC;AA9CD,wBA8CC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
export declare class WebpackConfigSerializationUtil {
|
|
3
|
+
static serializablePlugin<OptType, T extends {
|
|
4
|
+
apply(..._: any[]): void;
|
|
5
|
+
}>(name: string, PluginConstructor: new () => T): webpack.WebpackPluginInstance;
|
|
6
|
+
static serializablePlugin<OptType, T extends {
|
|
7
|
+
apply(..._: any[]): void;
|
|
8
|
+
}>(name: string, PluginConstructor: new (_: OptType) => T, options: OptType): webpack.WebpackPluginInstance;
|
|
9
|
+
static configToString(config: webpack.Configuration): string;
|
|
10
|
+
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export class WebpackConfigSerializationUtil {
|
|
11
|
-
static serializablePlugin<OptType, T extends {apply(..._: any[]): void}>(name: string, PluginConstructor: new () => T): webpack.WebpackPluginInstance;
|
|
12
|
-
static serializablePlugin<OptType, T extends {apply(..._: any[]): void}>(name: string, PluginConstructor: new (_: OptType) => T, options: OptType): webpack.WebpackPluginInstance;
|
|
13
|
-
static serializablePlugin<OptType, T extends {apply(..._: any[]): void}>(name: string, PluginConstructor: new (_?: OptType) => T, options?: OptType): webpack.WebpackPluginInstance {
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WebpackConfigSerializationUtil = void 0;
|
|
7
|
+
const pretty_format_1 = __importDefault(require("pretty-format"));
|
|
8
|
+
class WebpackConfigSerializationUtil {
|
|
9
|
+
static serializablePlugin(name, PluginConstructor, options) {
|
|
14
10
|
const plugin = new PluginConstructor(options);
|
|
15
11
|
return Object.defineProperty(plugin, "toWebpackConfigSerializableType", {
|
|
16
|
-
value()
|
|
12
|
+
value() {
|
|
17
13
|
return {
|
|
18
14
|
"@@WP_CONFIG_GEN_TYPE": "WebpackPluginConstructorCall",
|
|
19
15
|
pluginName: name,
|
|
@@ -22,9 +18,8 @@ export class WebpackConfigSerializationUtil {
|
|
|
22
18
|
},
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const configString = prettyFormat(config, {
|
|
21
|
+
static configToString(config) {
|
|
22
|
+
const configString = (0, pretty_format_1.default)(config, {
|
|
28
23
|
callToJSON: true,
|
|
29
24
|
escapeRegex: false,
|
|
30
25
|
escapeString: false,
|
|
@@ -32,22 +27,23 @@ export class WebpackConfigSerializationUtil {
|
|
|
32
27
|
printFunctionName: false,
|
|
33
28
|
plugins: [
|
|
34
29
|
{
|
|
35
|
-
test(val
|
|
30
|
+
test(val) {
|
|
36
31
|
try {
|
|
37
32
|
return typeof val.toWebpackConfigSerializableType === "function";
|
|
38
|
-
}
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
39
35
|
return false;
|
|
40
36
|
}
|
|
41
37
|
},
|
|
42
|
-
serialize(val
|
|
43
|
-
const _ = val.toWebpackConfigSerializableType()
|
|
38
|
+
serialize(val, config, indentation, depth, refs, printer) {
|
|
39
|
+
const _ = val.toWebpackConfigSerializableType();
|
|
44
40
|
return `new ${_.pluginName}(${printer(_.pluginOptions, config, indentation, depth, refs)})`;
|
|
45
41
|
},
|
|
46
42
|
},
|
|
47
43
|
],
|
|
48
44
|
});
|
|
49
45
|
try {
|
|
50
|
-
const {format} = require("prettier")
|
|
46
|
+
const { format } = require("prettier");
|
|
51
47
|
return format("module.exports = " + configString, {
|
|
52
48
|
arrowParens: "avoid",
|
|
53
49
|
bracketSpacing: false,
|
|
@@ -56,9 +52,12 @@ export class WebpackConfigSerializationUtil {
|
|
|
56
52
|
useTabs: false,
|
|
57
53
|
filepath: "webpack.config.js",
|
|
58
54
|
});
|
|
59
|
-
}
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
60
57
|
// Either prettier cannot be loaded, or formatting failed, return the unformatted config as a fallback.
|
|
61
58
|
return configString;
|
|
62
59
|
}
|
|
63
60
|
}
|
|
64
61
|
}
|
|
62
|
+
exports.WebpackConfigSerializationUtil = WebpackConfigSerializationUtil;
|
|
63
|
+
//# sourceMappingURL=WebpackConfigSerializationUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackConfigSerializationUtil.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackConfigSerializationUtil.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAyC;AASzC,MAAa,8BAA8B;IAGvC,MAAM,CAAC,kBAAkB,CAAgD,IAAY,EAAE,iBAAyC,EAAE,OAAiB;QAC/I,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,iCAAiC,EAAE;YACpE,KAAK;gBACD,OAAO;oBACH,sBAAsB,EAAE,8BAA8B;oBACtD,UAAU,EAAE,IAAI;oBAChB,aAAa,EAAE,OAAO;iBACzB,CAAC;YACN,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,MAAM,CAAC,cAAc,CAAC,MAA6B;QAC/C,MAAM,YAAY,GAAG,IAAA,uBAAY,EAAC,MAAM,EAAE;YACtC,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,KAAK;YACnB,GAAG,EAAE,IAAI;YACT,iBAAiB,EAAE,KAAK;YACxB,OAAO,EAAE;gBACL;oBACI,IAAI,CAAC,GAAQ;wBACT,IAAI;4BACA,OAAO,OAAO,GAAG,CAAC,+BAA+B,KAAK,UAAU,CAAC;yBACpE;wBAAC,WAAM;4BACJ,OAAO,KAAK,CAAC;yBAChB;oBACL,CAAC;oBACD,SAAS,CAAC,GAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO;wBACzD,MAAM,CAAC,GAAG,GAAG,CAAC,+BAA+B,EAAyC,CAAC;wBACvF,OAAO,OAAO,CAAC,CAAC,UAAU,IAAI,OAAO,CAAC,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC;oBAChG,CAAC;iBACJ;aACJ;SACJ,CAAC,CAAC;QACH,IAAI;YACA,MAAM,EAAC,MAAM,EAAC,GAAG,OAAO,CAAC,UAAU,CAA8B,CAAC;YAClE,OAAO,MAAM,CAAC,mBAAmB,GAAG,YAAY,EAAE;gBAC9C,WAAW,EAAE,OAAO;gBACpB,cAAc,EAAE,KAAK;gBACrB,UAAU,EAAE,GAAG;gBACf,QAAQ,EAAE,CAAC;gBACX,OAAO,EAAE,KAAK;gBACd,QAAQ,EAAE,mBAAmB;aAChC,CAAC,CAAC;SACN;QAAC,WAAM;YACJ,uGAAuG;YACvG,OAAO,YAAY,CAAC;SACvB;IACL,CAAC;CACJ;AAtDD,wEAsDC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
import type { EntryDescriptor } from "../type";
|
|
3
|
+
interface WebpackEntryFactoryOptions {
|
|
4
|
+
configEntryDescriptors: EntryDescriptor[];
|
|
5
|
+
}
|
|
6
|
+
export declare class WebpackEntryFactory {
|
|
7
|
+
static generate({ configEntryDescriptors }: WebpackEntryFactoryOptions): NonNullable<webpack.Configuration["entry"]>;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackEntryFactory = void 0;
|
|
4
|
+
class WebpackEntryFactory {
|
|
5
|
+
static generate({ configEntryDescriptors }) {
|
|
6
|
+
const entry = {};
|
|
7
|
+
for (const { name, entryPath } of configEntryDescriptors) {
|
|
8
|
+
entry[name] = [entryPath];
|
|
9
|
+
}
|
|
10
|
+
return entry;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.WebpackEntryFactory = WebpackEntryFactory;
|
|
14
|
+
//# sourceMappingURL=WebpackEntryFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackEntryFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackEntryFactory.ts"],"names":[],"mappings":";;;AAWA,MAAa,mBAAmB;IAC5B,MAAM,CAAC,QAAQ,CAAC,EAAC,sBAAsB,EAA6B;QAChE,MAAM,KAAK,GAAuB,EAAE,CAAC;QAErC,KAAK,MAAM,EAAC,IAAI,EAAE,SAAS,EAAC,IAAI,sBAAsB,EAAE;YACpD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SAC7B;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AAVD,kDAUC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface WebpackOutputPublicURLFactoryOptions {
|
|
2
|
+
env: string | null;
|
|
3
|
+
/**
|
|
4
|
+
* Function to dynamically compute additional webpack config from `env`.
|
|
5
|
+
* Should validates if the config contains `publicUrl` field.
|
|
6
|
+
*/
|
|
7
|
+
webpackPublicPath: string | ((env: string) => string) | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare class WebpackOutputPublicURLFactory {
|
|
10
|
+
static generate({ env, webpackPublicPath }: WebpackOutputPublicURLFactoryOptions): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackOutputPublicURLFactory = void 0;
|
|
4
|
+
class WebpackOutputPublicURLFactory {
|
|
5
|
+
static generate({ env, webpackPublicPath }) {
|
|
6
|
+
if (!env || !webpackPublicPath) {
|
|
7
|
+
return "/";
|
|
8
|
+
}
|
|
9
|
+
if (typeof webpackPublicPath === "string") {
|
|
10
|
+
return webpackPublicPath;
|
|
11
|
+
}
|
|
12
|
+
return webpackPublicPath(env);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.WebpackOutputPublicURLFactory = WebpackOutputPublicURLFactory;
|
|
16
|
+
//# sourceMappingURL=WebpackOutputPublicURLFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackOutputPublicURLFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackOutputPublicURLFactory.ts"],"names":[],"mappings":";;;AASA,MAAa,6BAA6B;IACtC,MAAM,CAAC,QAAQ,CAAC,EAAC,GAAG,EAAE,iBAAiB,EAAuC;QAC1E,IAAI,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE;YAC5B,OAAO,GAAG,CAAC;SACd;QAED,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE;YACvC,OAAO,iBAAiB,CAAC;SAC5B;QAED,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;CACJ;AAZD,sEAYC"}
|