@pinnacle0/webpack-util 0.3.26 → 0.3.27
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/TypescriptTypeChecker.d.ts +11 -0
- package/src/TypescriptTypeChecker.js +32 -0
- package/src/TypescriptTypeChecker.js.map +1 -0
- package/src/WebpackBuilder.d.ts +38 -0
- package/src/{WebpackBuilder.ts → WebpackBuilder.js} +51 -71
- 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/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 +27 -0
- package/src/WebpackConfigGenerator/Plugin/index.js +32 -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 +18 -0
- package/src/WebpackConfigGenerator/Rule/{ts.rule.ts → ts.rule.js} +16 -18
- 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 -10
- package/config/tsconfig.src.json +0 -12
- package/config/tsconfig.test.json +0 -11
- 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/TypescriptTypeChecker.ts +0 -29
- package/src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.ts +0 -24
- package/src/WebpackConfigGenerator/Plugin/css.plugin.ts +0 -31
- package/src/WebpackConfigGenerator/Plugin/html.plugin.ts +0 -47
- package/src/WebpackConfigGenerator/Plugin/index.ts +0 -33
- 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 @@
|
|
|
1
|
+
{"version":3,"file":"ts.rule.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Rule/ts.rule.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,6CAAwC;AAOxC;;;;;;;;;;GAUG;AACH,SAAgB,MAAM,CAAC,EAAC,gBAAgB,EAAE,WAAW,EAAO;IACxD,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,sEAAsE;IACtE,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,EAAE,IAAI;SACtB;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;AA/CD,wBA+CC"}
|
|
@@ -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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DynamicPathResolver } from "../type";
|
|
2
|
+
interface WebpackResolveAliasMapOptions {
|
|
3
|
+
env: string | null;
|
|
4
|
+
resolvers: DynamicPathResolver[];
|
|
5
|
+
}
|
|
6
|
+
export declare class WebpackResolveAliasFactory {
|
|
7
|
+
static generate({ env, resolvers }: WebpackResolveAliasMapOptions): {
|
|
8
|
+
[moduleAlias: string]: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export {};
|
package/src/WebpackConfigGenerator/{WebpackResolveAliasFactory.ts → WebpackResolveAliasFactory.js}
RENAMED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
resolvers
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class WebpackResolveAliasFactory {
|
|
9
|
-
static generate({env, resolvers}: WebpackResolveAliasMapOptions): {[moduleAlias: string]: string} {
|
|
10
|
-
const moduleAliasMap: {[moduleAlias: string]: string} = {};
|
|
11
|
-
|
|
12
|
-
for (const {prefix, resolver} of resolvers) {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackResolveAliasFactory = void 0;
|
|
4
|
+
class WebpackResolveAliasFactory {
|
|
5
|
+
static generate({ env, resolvers }) {
|
|
6
|
+
const moduleAliasMap = {};
|
|
7
|
+
for (const { prefix, resolver } of resolvers) {
|
|
13
8
|
if (prefix in moduleAliasMap) {
|
|
14
9
|
throw new Error(`Duplicated resolver prefix: ${prefix}`);
|
|
15
|
-
}
|
|
10
|
+
}
|
|
11
|
+
else if (prefix.trim() === "") {
|
|
16
12
|
throw new Error(`Resolver prefix cannot be empty`);
|
|
17
|
-
}
|
|
13
|
+
}
|
|
14
|
+
else if (/\s/.test(prefix)) {
|
|
18
15
|
throw new Error(`Resolver prefix cannot contain whitespace, received: ${prefix}`);
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
if (resolver) {
|
|
22
18
|
const resolvedRealPath = typeof resolver === "string" ? resolver : resolver(env);
|
|
23
19
|
if (resolvedRealPath) {
|
|
@@ -25,7 +21,8 @@ export class WebpackResolveAliasFactory {
|
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
return moduleAliasMap;
|
|
30
25
|
}
|
|
31
26
|
}
|
|
27
|
+
exports.WebpackResolveAliasFactory = WebpackResolveAliasFactory;
|
|
28
|
+
//# sourceMappingURL=WebpackResolveAliasFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackResolveAliasFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackResolveAliasFactory.ts"],"names":[],"mappings":";;;AAOA,MAAa,0BAA0B;IACnC,MAAM,CAAC,QAAQ,CAAC,EAAC,GAAG,EAAE,SAAS,EAAgC;QAC3D,MAAM,cAAc,GAAoC,EAAE,CAAC;QAE3D,KAAK,MAAM,EAAC,MAAM,EAAE,QAAQ,EAAC,IAAI,SAAS,EAAE;YACxC,IAAI,MAAM,IAAI,cAAc,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,MAAM,EAAE,CAAC,CAAC;aAC5D;iBAAM,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;aACtD;iBAAM,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;gBAC1B,MAAM,IAAI,KAAK,CAAC,wDAAwD,MAAM,EAAE,CAAC,CAAC;aACrF;YAED,IAAI,QAAQ,EAAE;gBACV,MAAM,gBAAgB,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBACjF,IAAI,gBAAgB,EAAE;oBAClB,cAAc,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAC;iBAC7C;aACJ;SACJ;QAED,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AAvBD,gEAuBC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface WebpackResolveExtensionsFactoryOptions {
|
|
2
|
+
prioritizedExtensionPrefixes?: string[] | undefined;
|
|
3
|
+
}
|
|
4
|
+
export declare class WebpackResolveExtensionsFactory {
|
|
5
|
+
static generate({ prioritizedExtensionPrefixes }: WebpackResolveExtensionsFactoryOptions): string[];
|
|
6
|
+
}
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackResolveExtensionsFactory = void 0;
|
|
4
|
+
const Constant_1 = require("../Constant");
|
|
5
|
+
class WebpackResolveExtensionsFactory {
|
|
6
|
+
static generate({ prioritizedExtensionPrefixes = [] }) {
|
|
7
|
+
const resolveExtensions = [];
|
|
8
|
+
for (const prefix of prioritizedExtensionPrefixes) {
|
|
9
|
+
resolveExtensions.push(...Constant_1.Constant.resolveExtensions.map(_ => `.${prefix}${_}`));
|
|
10
|
+
}
|
|
11
|
+
resolveExtensions.push(...Constant_1.Constant.resolveExtensions);
|
|
12
|
+
return resolveExtensions;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.WebpackResolveExtensionsFactory = WebpackResolveExtensionsFactory;
|
|
16
|
+
//# sourceMappingURL=WebpackResolveExtensionsFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackResolveExtensionsFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackResolveExtensionsFactory.ts"],"names":[],"mappings":";;;AAAA,0CAAqC;AAMrC,MAAa,+BAA+B;IACxC,MAAM,CAAC,QAAQ,CAAC,EAAC,4BAA4B,GAAG,EAAE,EAAyC;QACvF,MAAM,iBAAiB,GAAG,EAAE,CAAC;QAE7B,KAAK,MAAM,MAAM,IAAI,4BAA4B,EAAE;YAC/C,iBAAiB,CAAC,IAAI,CAAC,GAAG,mBAAQ,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;SACpF;QAED,iBAAiB,CAAC,IAAI,CAAC,GAAG,mBAAQ,CAAC,iBAAiB,CAAC,CAAC;QAEtD,OAAO,iBAAiB,CAAC;IAC7B,CAAC;CACJ;AAZD,0EAYC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
static generate({projectSrcDirectory}: WebpackResolveModulesFactoryOptions): string[] {
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebpackResolveModulesFactory = void 0;
|
|
4
|
+
class WebpackResolveModulesFactory {
|
|
5
|
+
static generate({ projectSrcDirectory }) {
|
|
7
6
|
const resolveModules = [];
|
|
8
|
-
|
|
9
7
|
/**
|
|
10
8
|
* To let webpack know how to resolve non-relative paths when `tsconfig.json#compilerOptions.baseUrl` is set to "./src"
|
|
11
9
|
* Maybe refactor to a better resolution/aliasing solution later(?)
|
|
@@ -26,13 +24,13 @@ export class WebpackResolveModulesFactory {
|
|
|
26
24
|
* ```
|
|
27
25
|
*/
|
|
28
26
|
resolveModules.push(projectSrcDirectory);
|
|
29
|
-
|
|
30
27
|
/**
|
|
31
28
|
* The default behavior to resolve non-relative paths is by looking inside `node_modules` folder.
|
|
32
29
|
* Put at the end so this has the lowest precedence.
|
|
33
30
|
*/
|
|
34
31
|
resolveModules.push("node_modules");
|
|
35
|
-
|
|
36
32
|
return resolveModules;
|
|
37
33
|
}
|
|
38
34
|
}
|
|
35
|
+
exports.WebpackResolveModulesFactory = WebpackResolveModulesFactory;
|
|
36
|
+
//# sourceMappingURL=WebpackResolveModulesFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackResolveModulesFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/WebpackResolveModulesFactory.ts"],"names":[],"mappings":";;;AAIA,MAAa,4BAA4B;IACrC,MAAM,CAAC,QAAQ,CAAC,EAAC,mBAAmB,EAAsC;QACtE,MAAM,cAAc,GAAG,EAAE,CAAC;QAE1B;;;;;;;;;;;;;;;;;;WAkBG;QACH,cAAc,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAEzC;;;WAGG;QACH,cAAc,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEpC,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AAjCD,oEAiCC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
import type { WebpackConfigGeneratorOptions } from "../type";
|
|
3
|
+
/**
|
|
4
|
+
* Generates a webpack config with sane defaults.
|
|
5
|
+
*/
|
|
6
|
+
export declare class WebpackConfigGenerator {
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly env;
|
|
9
|
+
private readonly projectDirectory;
|
|
10
|
+
private readonly projectSrcDirectory;
|
|
11
|
+
private readonly tsconfigFilepath;
|
|
12
|
+
private readonly enableProfiling;
|
|
13
|
+
private readonly maxEntryPointKiloByte;
|
|
14
|
+
private readonly maxAssetKiloByte;
|
|
15
|
+
private readonly isFastMode;
|
|
16
|
+
private readonly verbose;
|
|
17
|
+
private readonly defineVars;
|
|
18
|
+
private readonly extraExtensionsForOtherRule;
|
|
19
|
+
private readonly configEntryDescriptors;
|
|
20
|
+
private readonly entry;
|
|
21
|
+
private readonly htmlWebpackPluginInstances;
|
|
22
|
+
private readonly resolveExtensions;
|
|
23
|
+
private readonly resolveModules;
|
|
24
|
+
private readonly resolveAliases;
|
|
25
|
+
private readonly outputPublicPath;
|
|
26
|
+
private readonly logger;
|
|
27
|
+
constructor(options: WebpackConfigGeneratorOptions);
|
|
28
|
+
development(): webpack.Configuration;
|
|
29
|
+
production(outputDirectory: string): webpack.Configuration;
|
|
30
|
+
}
|
|
31
|
+
export type { WebpackConfigGeneratorOptions };
|
|
@@ -0,0 +1,191 @@
|
|
|
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.WebpackConfigGenerator = void 0;
|
|
7
|
+
const devtool_util_1 = require("@pinnacle0/devtool-util");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const Constant_1 = require("../Constant");
|
|
10
|
+
const CoreUtil_1 = require("../CoreUtil");
|
|
11
|
+
const ConfigEntryDescriptorsFactory_1 = require("./ConfigEntryDescriptorsFactory");
|
|
12
|
+
const HTMLWebpackPluginsFactory_1 = require("./HTMLWebpackPluginsFactory");
|
|
13
|
+
const WebpackConfigSerializationUtil_1 = require("./WebpackConfigSerializationUtil");
|
|
14
|
+
const WebpackEntryFactory_1 = require("./WebpackEntryFactory");
|
|
15
|
+
const WebpackOutputPublicURLFactory_1 = require("./WebpackOutputPublicURLFactory");
|
|
16
|
+
const WebpackResolveAliasFactory_1 = require("./WebpackResolveAliasFactory");
|
|
17
|
+
const WebpackResolveExtensionsFactory_1 = require("./WebpackResolveExtensionsFactory");
|
|
18
|
+
const WebpackResolveModulesFactory_1 = require("./WebpackResolveModulesFactory");
|
|
19
|
+
const Plugin_1 = require("./Plugin");
|
|
20
|
+
const Rule_1 = require("./Rule");
|
|
21
|
+
/**
|
|
22
|
+
* Generates a webpack config with sane defaults.
|
|
23
|
+
*/
|
|
24
|
+
class WebpackConfigGenerator {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
var _a, _b, _c;
|
|
27
|
+
this.options = options;
|
|
28
|
+
this.logger = devtool_util_1.Utility.createConsoleLogger("WebpackConfigGenerator");
|
|
29
|
+
this.env = CoreUtil_1.CoreUtil.currentEnv();
|
|
30
|
+
this.projectDirectory = options.projectDirectory;
|
|
31
|
+
this.projectSrcDirectory = path_1.default.join(options.projectDirectory, "src");
|
|
32
|
+
this.tsconfigFilepath = path_1.default.join(options.projectDirectory, "tsconfig.json");
|
|
33
|
+
this.enableProfiling = CoreUtil_1.CoreUtil.profilingEnabled();
|
|
34
|
+
this.isFastMode = CoreUtil_1.CoreUtil.isFastMode();
|
|
35
|
+
this.maxEntryPointKiloByte = (_a = options.maxEntryPointKiloByte) !== null && _a !== void 0 ? _a : Constant_1.Constant.maxEntryPointKiloByte;
|
|
36
|
+
this.maxAssetKiloByte = (_b = options.maxAssetKiloByte) !== null && _b !== void 0 ? _b : Constant_1.Constant.maxAssetKiloByte;
|
|
37
|
+
this.verbose = options.verbose || false;
|
|
38
|
+
this.defineVars = options.defineVars || {};
|
|
39
|
+
this.extraExtensionsForOtherRule = options.extraExtensionsForOtherRule || [];
|
|
40
|
+
this.configEntryDescriptors = ConfigEntryDescriptorsFactory_1.ConfigEntryDescriptorsFactory.generate({
|
|
41
|
+
indexName: options.indexName || "index",
|
|
42
|
+
projectSrcDirectory: this.projectSrcDirectory,
|
|
43
|
+
extraEntries: options.extraEntries || {},
|
|
44
|
+
});
|
|
45
|
+
this.entry = WebpackEntryFactory_1.WebpackEntryFactory.generate({
|
|
46
|
+
configEntryDescriptors: this.configEntryDescriptors,
|
|
47
|
+
});
|
|
48
|
+
this.htmlWebpackPluginInstances = HTMLWebpackPluginsFactory_1.HTMLWebpackPluginsFactory.generate({
|
|
49
|
+
configEntryDescriptors: this.configEntryDescriptors,
|
|
50
|
+
});
|
|
51
|
+
this.outputPublicPath = WebpackOutputPublicURLFactory_1.WebpackOutputPublicURLFactory.generate({
|
|
52
|
+
env: this.env,
|
|
53
|
+
webpackPublicPath: options.webpackPublicPath,
|
|
54
|
+
});
|
|
55
|
+
this.resolveExtensions = WebpackResolveExtensionsFactory_1.WebpackResolveExtensionsFactory.generate({
|
|
56
|
+
prioritizedExtensionPrefixes: options.prioritizedExtensionPrefixes,
|
|
57
|
+
});
|
|
58
|
+
this.resolveModules = WebpackResolveModulesFactory_1.WebpackResolveModulesFactory.generate({
|
|
59
|
+
projectSrcDirectory: this.projectSrcDirectory,
|
|
60
|
+
});
|
|
61
|
+
this.resolveAliases = WebpackResolveAliasFactory_1.WebpackResolveAliasFactory.generate({
|
|
62
|
+
env: this.env,
|
|
63
|
+
resolvers: (_c = options.dynamicPathResolvers) !== null && _c !== void 0 ? _c : [],
|
|
64
|
+
});
|
|
65
|
+
this.logger.info("Config constructed:");
|
|
66
|
+
for (const info of [
|
|
67
|
+
`-- Code Checking: ${this.isFastMode ? "Minimal Check" : "Default"}`,
|
|
68
|
+
`-- Env: ${this.env || "[N/A]"}`,
|
|
69
|
+
`-- Src Directory: ${this.projectSrcDirectory}`,
|
|
70
|
+
`-- HTML Entries: ${Object.keys(this.entry).join(" / ")}`,
|
|
71
|
+
`-- Webpack Public URL: ${this.outputPublicPath}`,
|
|
72
|
+
`-- Dynamic Aliases: ${JSON.stringify(this.resolveAliases, null, 4)}`,
|
|
73
|
+
`-- Use Cache: ${this.env === null}`,
|
|
74
|
+
]) {
|
|
75
|
+
console.info(info);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
development() {
|
|
79
|
+
const config = {
|
|
80
|
+
mode: "development",
|
|
81
|
+
entry: this.entry,
|
|
82
|
+
target: "web",
|
|
83
|
+
output: {
|
|
84
|
+
filename: "static/js/[name].js",
|
|
85
|
+
publicPath: "/",
|
|
86
|
+
},
|
|
87
|
+
resolve: {
|
|
88
|
+
extensions: this.resolveExtensions,
|
|
89
|
+
modules: this.resolveModules,
|
|
90
|
+
alias: this.resolveAliases,
|
|
91
|
+
},
|
|
92
|
+
devtool: "inline-cheap-module-source-map",
|
|
93
|
+
optimization: {
|
|
94
|
+
usedExports: true,
|
|
95
|
+
splitChunks: {
|
|
96
|
+
automaticNameDelimiter: "-",
|
|
97
|
+
maxAsyncRequests: 30,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
module: {
|
|
101
|
+
rules: [
|
|
102
|
+
Rule_1.Rule.ts({ tsconfigFilepath: this.tsconfigFilepath, fastRefresh: true }),
|
|
103
|
+
Rule_1.Rule.stylesheet({ minimize: false }),
|
|
104
|
+
Rule_1.Rule.image(),
|
|
105
|
+
Rule_1.Rule.other({ extraExtensionsForOtherRule: this.extraExtensionsForOtherRule }),
|
|
106
|
+
// prettier-format-preserve
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
plugins: [
|
|
110
|
+
...this.htmlWebpackPluginInstances,
|
|
111
|
+
Plugin_1.Plugin.ignoreMomentLocale(),
|
|
112
|
+
Plugin_1.Plugin.reactRefresh(),
|
|
113
|
+
Plugin_1.Plugin.webpack.progress({ enableProfiling: false }),
|
|
114
|
+
Plugin_1.Plugin.webpack.define(this.defineVars),
|
|
115
|
+
// prettier-format-preserve
|
|
116
|
+
],
|
|
117
|
+
cache: this.env === null
|
|
118
|
+
? {
|
|
119
|
+
type: "filesystem",
|
|
120
|
+
cacheDirectory: path_1.default.join(this.projectDirectory, ".webpack-cache"),
|
|
121
|
+
}
|
|
122
|
+
: false,
|
|
123
|
+
};
|
|
124
|
+
if (this.verbose || CoreUtil_1.CoreUtil.verbose()) {
|
|
125
|
+
this.logger.info("Full webpack config:");
|
|
126
|
+
console.info(WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.configToString(config));
|
|
127
|
+
}
|
|
128
|
+
return config;
|
|
129
|
+
}
|
|
130
|
+
production(outputDirectory) {
|
|
131
|
+
const config = {
|
|
132
|
+
mode: "production",
|
|
133
|
+
entry: this.entry,
|
|
134
|
+
target: ["web", "es5"],
|
|
135
|
+
output: {
|
|
136
|
+
path: outputDirectory,
|
|
137
|
+
filename: this.enableProfiling ? "static/js/[name].js" : pathInfo => this.configEntryDescriptors.find(_ => _.name === pathInfo.chunk.name).outputFilename,
|
|
138
|
+
chunkFilename: this.enableProfiling ? "static/js/[id].[name].js" : "static/js/[id].[chunkhash:8].js",
|
|
139
|
+
publicPath: this.outputPublicPath,
|
|
140
|
+
crossOriginLoading: "anonymous",
|
|
141
|
+
},
|
|
142
|
+
resolve: {
|
|
143
|
+
extensions: this.resolveExtensions,
|
|
144
|
+
modules: this.resolveModules,
|
|
145
|
+
alias: this.resolveAliases,
|
|
146
|
+
},
|
|
147
|
+
bail: true,
|
|
148
|
+
optimization: {
|
|
149
|
+
splitChunks: {
|
|
150
|
+
automaticNameDelimiter: "-",
|
|
151
|
+
maxAsyncRequests: 30,
|
|
152
|
+
},
|
|
153
|
+
minimizer: [
|
|
154
|
+
Plugin_1.Plugin.minimizer.terser({ sourceMap: true }),
|
|
155
|
+
Plugin_1.Plugin.minimizer.css(),
|
|
156
|
+
// prettier-format-preserve
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
performance: {
|
|
160
|
+
maxEntrypointSize: this.enableProfiling ? Number.MAX_SAFE_INTEGER : this.maxEntryPointKiloByte * 1000,
|
|
161
|
+
maxAssetSize: this.maxAssetKiloByte * 1000,
|
|
162
|
+
assetFilter: (filename) => Constant_1.Constant.mediaExtensions.concat(this.extraExtensionsForOtherRule).every(_ => !filename.endsWith(_)),
|
|
163
|
+
},
|
|
164
|
+
module: {
|
|
165
|
+
rules: [
|
|
166
|
+
Rule_1.Rule.ts({ tsconfigFilepath: this.tsconfigFilepath, fastRefresh: false }),
|
|
167
|
+
Rule_1.Rule.stylesheet({ minimize: true }),
|
|
168
|
+
Rule_1.Rule.image(),
|
|
169
|
+
Rule_1.Rule.other({ extraExtensionsForOtherRule: this.extraExtensionsForOtherRule }),
|
|
170
|
+
// prettier-format-preserve
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
plugins: [
|
|
174
|
+
...this.htmlWebpackPluginInstances,
|
|
175
|
+
Plugin_1.Plugin.scriptTagCrossOriginPlugin(),
|
|
176
|
+
Plugin_1.Plugin.ignoreMomentLocale(),
|
|
177
|
+
Plugin_1.Plugin.fileOutput.miniCssExtract({ enableProfiling: this.enableProfiling }),
|
|
178
|
+
...(this.enableProfiling ? [Plugin_1.Plugin.webpack.progress({ enableProfiling: true })] : []),
|
|
179
|
+
Plugin_1.Plugin.webpack.define(this.defineVars),
|
|
180
|
+
// prettier-format-preserve
|
|
181
|
+
],
|
|
182
|
+
};
|
|
183
|
+
if (this.verbose || CoreUtil_1.CoreUtil.verbose()) {
|
|
184
|
+
this.logger.info("Full webpack config:");
|
|
185
|
+
console.info(WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.configToString(config));
|
|
186
|
+
}
|
|
187
|
+
return config;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.WebpackConfigGenerator = WebpackConfigGenerator;
|
|
191
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/index.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgD;AAChD,gDAAwB;AAExB,0CAAqC;AACrC,0CAAqC;AAErC,mFAA8E;AAC9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C3E,2BAA2B;iBAC9B;aACJ;YACD,OAAO,EAAE;gBACL,GAAG,IAAI,CAAC,0BAA0B;gBAClC,eAAM,CAAC,0BAA0B,EAAE;gBACnC,eAAM,CAAC,kBAAkB,EAAE;gBAC3B,eAAM,CAAC,UAAU,CAAC,cAAc,CAAC,EAAC,eAAe,EAAE,IAAI,CAAC,eAAe,EAAC,CAAC;gBACzE,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAC,eAAe,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;gBACnF,eAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;gBACtC,2BAA2B;aAC9B;SACJ,CAAC;QACF,IAAI,IAAI,CAAC,OAAO,IAAI,mBAAQ,CAAC,OAAO,EAAE,EAAE;YACpC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,+DAA8B,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;SACvE;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA9LD,wDA8LC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Application as ExpressApplication } from "express";
|
|
2
|
+
import type { WebpackConfigGeneratorOptions } from "./WebpackConfigGenerator";
|
|
3
|
+
export interface WebpackServerStarterOptions extends Pick<WebpackConfigGeneratorOptions, "projectDirectory" | "dynamicPathResolvers" | "extraEntries" | "prioritizedExtensionPrefixes" | "defineVars" | "extraExtensionsForOtherRule"> {
|
|
4
|
+
port: number;
|
|
5
|
+
apiProxy?: {
|
|
6
|
+
target: string;
|
|
7
|
+
context: string[];
|
|
8
|
+
};
|
|
9
|
+
interceptExpressApp?: (app: ExpressApplication) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Start webpack dev server, by creating WebpackServerStarter instance and then run.
|
|
13
|
+
*
|
|
14
|
+
***************************************
|
|
15
|
+
*
|
|
16
|
+
* Add "--env envName" to command line, if you want to switch config folder dynamically.
|
|
17
|
+
*/
|
|
18
|
+
export declare class WebpackServerStarter {
|
|
19
|
+
private readonly devServerConfigContentBase;
|
|
20
|
+
private readonly onBeforeSetupMiddleware;
|
|
21
|
+
private readonly port;
|
|
22
|
+
private readonly apiProxy;
|
|
23
|
+
private readonly logger;
|
|
24
|
+
private readonly webpackConfig;
|
|
25
|
+
constructor({ projectDirectory, port, apiProxy, interceptExpressApp, dynamicPathResolvers, extraEntries, prioritizedExtensionPrefixes, defineVars, extraExtensionsForOtherRule, }: WebpackServerStarterOptions);
|
|
26
|
+
run(): Promise<void>;
|
|
27
|
+
private createDevServerInstance;
|
|
28
|
+
}
|