@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
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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.WebpackBuilder = void 0;
|
|
7
|
+
const devtool_util_1 = require("@pinnacle0/devtool-util");
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
11
|
+
const CoreUtil_1 = require("./CoreUtil");
|
|
12
|
+
const WebpackConfigGenerator_1 = require("./WebpackConfigGenerator");
|
|
13
|
+
const CanadyarnRunner_1 = require("./CanadyarnRunner");
|
|
14
|
+
const ProjectStructureChecker_1 = require("./ProjectStructureChecker");
|
|
15
|
+
const TypescriptTypeChecker_1 = require("./TypescriptTypeChecker");
|
|
16
|
+
const TestRunner_1 = require("./TestRunner");
|
|
17
|
+
const CodeStyleChecker_1 = require("./CodeStyleChecker");
|
|
19
18
|
/**
|
|
20
19
|
* Build the website by webpack.
|
|
21
20
|
*
|
|
@@ -30,55 +29,40 @@ export interface WebpackBuilderOptions extends WebpackConfigGeneratorOptions, In
|
|
|
30
29
|
*
|
|
31
30
|
* Add "--mode fast" to command line, if you want to skip style and lint checks.
|
|
32
31
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
private readonly projectProfilingJSONOutputPath: string;
|
|
39
|
-
private readonly outputDirectory: string;
|
|
40
|
-
private readonly webpackConfig: webpack.Configuration;
|
|
41
|
-
private readonly isFastMode: boolean;
|
|
42
|
-
private readonly enableProfiling: boolean;
|
|
43
|
-
private readonly onSuccess?: (() => void) | undefined;
|
|
44
|
-
|
|
45
|
-
private readonly logger = Utility.createConsoleLogger("WebpackBuilder");
|
|
46
|
-
|
|
47
|
-
constructor(options: WebpackBuilderOptions) {
|
|
48
|
-
const webpackConfigGenerator = new WebpackConfigGenerator(options);
|
|
49
|
-
|
|
32
|
+
class WebpackBuilder {
|
|
33
|
+
constructor(options) {
|
|
34
|
+
var _a;
|
|
35
|
+
this.logger = devtool_util_1.Utility.createConsoleLogger("WebpackBuilder");
|
|
36
|
+
const webpackConfigGenerator = new WebpackConfigGenerator_1.WebpackConfigGenerator(options);
|
|
50
37
|
this.projectDirectory = options.projectDirectory;
|
|
51
38
|
this.rootDirectory = options.rootDirectory ? options.rootDirectory : this.projectDirectory;
|
|
52
|
-
this.extraCheckDirectories = options.extraCheckDirectories
|
|
53
|
-
this.projectStaticDirectory =
|
|
54
|
-
this.projectProfilingJSONOutputPath =
|
|
55
|
-
this.outputDirectory =
|
|
56
|
-
|
|
57
|
-
this.
|
|
58
|
-
this.enableProfiling = CoreUtil.profilingEnabled();
|
|
39
|
+
this.extraCheckDirectories = (_a = options.extraCheckDirectories) !== null && _a !== void 0 ? _a : [];
|
|
40
|
+
this.projectStaticDirectory = path_1.default.join(this.projectDirectory, "static");
|
|
41
|
+
this.projectProfilingJSONOutputPath = path_1.default.join(this.projectDirectory, "profile.json");
|
|
42
|
+
this.outputDirectory = path_1.default.join(this.projectDirectory, "build/dist");
|
|
43
|
+
this.isFastMode = CoreUtil_1.CoreUtil.isFastMode();
|
|
44
|
+
this.enableProfiling = CoreUtil_1.CoreUtil.profilingEnabled();
|
|
59
45
|
this.onSuccess = options.onSuccess;
|
|
60
|
-
|
|
61
46
|
this.webpackConfig = webpackConfigGenerator.production(this.outputDirectory);
|
|
62
47
|
}
|
|
63
|
-
|
|
64
48
|
run() {
|
|
65
49
|
if (!this.isFastMode) {
|
|
66
|
-
new CanadyarnRunner({
|
|
50
|
+
new CanadyarnRunner_1.CanadyarnRunner({
|
|
67
51
|
rootDirectory: this.rootDirectory,
|
|
68
52
|
}).run();
|
|
69
|
-
new ProjectStructureChecker({
|
|
53
|
+
new ProjectStructureChecker_1.ProjectStructureChecker({
|
|
70
54
|
projectDirectory: this.projectDirectory,
|
|
71
55
|
extraCheckDirectories: this.extraCheckDirectories,
|
|
72
56
|
}).run();
|
|
73
|
-
new TypescriptTypeChecker({
|
|
57
|
+
new TypescriptTypeChecker_1.TypescriptTypeChecker({
|
|
74
58
|
projectDirectory: this.projectDirectory,
|
|
75
59
|
extraCheckDirectories: this.extraCheckDirectories,
|
|
76
60
|
}).run();
|
|
77
|
-
new TestRunner({
|
|
61
|
+
new TestRunner_1.TestRunner({
|
|
78
62
|
projectDirectory: this.projectDirectory,
|
|
79
63
|
extraCheckDirectories: this.extraCheckDirectories,
|
|
80
64
|
}).run();
|
|
81
|
-
new CodeStyleChecker({
|
|
65
|
+
new CodeStyleChecker_1.CodeStyleChecker({
|
|
82
66
|
projectDirectory: this.projectDirectory,
|
|
83
67
|
extraCheckDirectories: this.extraCheckDirectories,
|
|
84
68
|
}).run();
|
|
@@ -87,52 +71,46 @@ export class WebpackBuilder {
|
|
|
87
71
|
this.copyStatic();
|
|
88
72
|
this.bundleByWebpack();
|
|
89
73
|
}
|
|
90
|
-
|
|
91
|
-
private cleanDistFolder() {
|
|
74
|
+
cleanDistFolder() {
|
|
92
75
|
this.logger.task("Cleaning build dist folder");
|
|
93
|
-
|
|
76
|
+
fs_extra_1.default.emptyDirSync(this.outputDirectory);
|
|
94
77
|
}
|
|
95
|
-
|
|
96
|
-
private copyStatic() {
|
|
78
|
+
copyStatic() {
|
|
97
79
|
this.logger.task("Copying static assets to build dist folder");
|
|
98
|
-
|
|
80
|
+
fs_extra_1.default.copySync(this.projectStaticDirectory, this.outputDirectory, { dereference: true });
|
|
99
81
|
}
|
|
100
|
-
|
|
101
|
-
private bundleByWebpack() {
|
|
82
|
+
bundleByWebpack() {
|
|
102
83
|
this.logger.task("Starting webpack");
|
|
103
|
-
|
|
104
|
-
webpack(this.webpackConfig).run((error?: Error | null, stats?: webpack.Stats) => {
|
|
84
|
+
(0, webpack_1.default)(this.webpackConfig).run((error, stats) => {
|
|
105
85
|
if (error) {
|
|
106
86
|
throw error;
|
|
107
|
-
}
|
|
87
|
+
}
|
|
88
|
+
else if (stats) {
|
|
108
89
|
const statsJSON = stats.toJson();
|
|
109
90
|
if (this.enableProfiling) {
|
|
110
91
|
this.logger.task(["Generating profile for analysis", this.projectProfilingJSONOutputPath]);
|
|
111
|
-
|
|
92
|
+
fs_extra_1.default.writeFileSync(this.projectProfilingJSONOutputPath, JSON.stringify(statsJSON, null, 2), { encoding: "utf8" });
|
|
112
93
|
}
|
|
113
|
-
|
|
114
94
|
if (stats.hasErrors() || stats.hasWarnings()) {
|
|
115
95
|
this.logger.error("Webpack compiled with the following errors/warnings:");
|
|
116
96
|
console.error(stats.toString("errors-warnings"));
|
|
117
97
|
process.exit(1);
|
|
118
98
|
}
|
|
119
|
-
|
|
120
99
|
this.logger.info("Build successfully");
|
|
121
|
-
|
|
122
100
|
if (this.onSuccess) {
|
|
123
101
|
this.logger.info("Running onSuccess callback");
|
|
124
102
|
this.onSuccess();
|
|
125
103
|
}
|
|
126
|
-
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
127
106
|
this.logger.error("Webpack compiler `run()` returns no `error` and no `stats`, this is unexpected.");
|
|
128
107
|
process.exit(1);
|
|
129
108
|
}
|
|
130
109
|
});
|
|
131
110
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const errors: any[] = [];
|
|
111
|
+
getRawWarningsAndErrors(info) {
|
|
112
|
+
const warnings = [];
|
|
113
|
+
const errors = [];
|
|
136
114
|
if (typeof info === "object" && info !== null) {
|
|
137
115
|
if (Array.isArray(info.warnings)) {
|
|
138
116
|
warnings.push(...info.warnings);
|
|
@@ -141,13 +119,15 @@ export class WebpackBuilder {
|
|
|
141
119
|
errors.push(...info.errors);
|
|
142
120
|
}
|
|
143
121
|
if (Array.isArray(info.children)) {
|
|
144
|
-
info.children.forEach((_
|
|
122
|
+
info.children.forEach((_) => {
|
|
145
123
|
const childInfo = this.getRawWarningsAndErrors(_);
|
|
146
124
|
warnings.push(...childInfo.warnings);
|
|
147
125
|
errors.push(...childInfo.errors);
|
|
148
126
|
});
|
|
149
127
|
}
|
|
150
128
|
}
|
|
151
|
-
return {warnings, errors};
|
|
129
|
+
return { warnings, errors };
|
|
152
130
|
}
|
|
153
131
|
}
|
|
132
|
+
exports.WebpackBuilder = WebpackBuilder;
|
|
133
|
+
//# sourceMappingURL=WebpackBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebpackBuilder.js","sourceRoot":"","sources":["../../src/WebpackBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAgD;AAChD,wDAA0B;AAC1B,gDAAwB;AACxB,sDAA8B;AAC9B,yCAAoC;AACpC,qEAAgE;AAChE,uDAAkD;AAClD,uEAAkE;AAClE,mEAA8D;AAC9D,6CAAwC;AACxC,yDAAoD;AAQpD;;;;;;;;;;;;;GAaG;AACH,MAAa,cAAc;IAcvB,YAAY,OAA8B;;QAFzB,WAAM,GAAG,sBAAO,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAGpE,MAAM,sBAAsB,GAAG,IAAI,+CAAsB,CAAC,OAAO,CAAC,CAAC;QAEnE,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC3F,IAAI,CAAC,qBAAqB,GAAG,MAAA,OAAO,CAAC,qBAAqB,mCAAI,EAAE,CAAC;QACjE,IAAI,CAAC,sBAAsB,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;QACzE,IAAI,CAAC,8BAA8B,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;QACvF,IAAI,CAAC,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC;QAEtE,IAAI,CAAC,UAAU,GAAG,mBAAQ,CAAC,UAAU,EAAE,CAAC;QACxC,IAAI,CAAC,eAAe,GA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ntryDescriptorsFactoryOptions {
|
|
3
|
+
indexName: string;
|
|
4
|
+
projectSrcDirectory: string;
|
|
5
|
+
extraEntries: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConfigEntryDescriptorsFactory {
|
|
8
|
+
static generate({ indexName, projectSrcDirectory, extraEntries }: ConfigEntryDescriptorsFactoryOptions): EntryDescriptor[];
|
|
9
|
+
private static createEntryDescriptor;
|
|
10
|
+
private static findEntryFilepath;
|
|
11
|
+
private static findEntryHTMLFilepath;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
static generate({indexName, projectSrcDirectory, extraEntries}: ConfigEntryDescriptorsFactoryOptions): EntryDescriptor[] {
|
|
14
|
-
const entryDescriptors: EntryDescriptor[] = [];
|
|
15
|
-
|
|
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.ConfigEntryDescriptorsFactory = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const Constant_1 = require("../Constant");
|
|
10
|
+
class ConfigEntryDescriptorsFactory {
|
|
11
|
+
static generate({ indexName, projectSrcDirectory, extraEntries }) {
|
|
12
|
+
const entryDescriptors = [];
|
|
16
13
|
const mainEntryDescriptor = ConfigEntryDescriptorsFactory.createEntryDescriptor({
|
|
17
14
|
name: indexName,
|
|
18
15
|
directory: projectSrcDirectory,
|
|
19
16
|
});
|
|
20
17
|
entryDescriptors.push(mainEntryDescriptor);
|
|
21
|
-
|
|
22
18
|
for (const [extraEntryName, extraEntryDirectory] of Object.entries(extraEntries)) {
|
|
23
19
|
const extraEntryDescriptor = ConfigEntryDescriptorsFactory.createEntryDescriptor({
|
|
24
20
|
name: extraEntryName,
|
|
@@ -26,55 +22,52 @@ export class ConfigEntryDescriptorsFactory {
|
|
|
26
22
|
});
|
|
27
23
|
entryDescriptors.push(extraEntryDescriptor);
|
|
28
24
|
}
|
|
29
|
-
|
|
30
25
|
return entryDescriptors;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
|
-
private static createEntryDescriptor({name, directory}: {name: string; directory: string}): EntryDescriptor {
|
|
27
|
+
static createEntryDescriptor({ name, directory }) {
|
|
34
28
|
const entryPath = ConfigEntryDescriptorsFactory.findEntryFilepath(directory);
|
|
35
29
|
const htmlPath = ConfigEntryDescriptorsFactory.findEntryHTMLFilepath(directory);
|
|
36
|
-
|
|
37
30
|
if (entryPath === null) {
|
|
38
|
-
throw new Error(`Cannot find entry file for "${name}" in "${directory}", files checked: ${Constant.mainEntryFilenames.join("/")}`);
|
|
31
|
+
throw new Error(`Cannot find entry file for "${name}" in "${directory}", files checked: ${Constant_1.Constant.mainEntryFilenames.join("/")}`);
|
|
39
32
|
}
|
|
40
|
-
|
|
41
33
|
if (htmlPath === null) {
|
|
42
34
|
// Output is a pure js entry (without a companion `index.html` template file)
|
|
43
35
|
// Do not include a hash in the output filenames.
|
|
44
36
|
// One particular use case for this is create a "third-party-error-handler" pure js entry,
|
|
45
37
|
// so this static filename can be hard coded at our backend.
|
|
46
38
|
const outputFilename = "static/js/[name].js";
|
|
47
|
-
return {name, entryPath, outputFilename};
|
|
48
|
-
}
|
|
39
|
+
return { name, entryPath, outputFilename };
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
49
42
|
// Output is an html entry (with a companion `index.html` template file)
|
|
50
43
|
// We might want to include a hash to the output filenames
|
|
51
44
|
// (don't set the output filename to contain hash for profiling build).
|
|
52
45
|
const outputFilename = "static/js/[chunkhash:8].js";
|
|
53
|
-
return {name, entryPath, outputFilename, htmlPath};
|
|
46
|
+
return { name, entryPath, outputFilename, htmlPath };
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (!(fs.existsSync(searchDirectory) && fs.statSync(searchDirectory).isDirectory())) {
|
|
49
|
+
static findEntryFilepath(searchDirectory) {
|
|
50
|
+
if (!(fs_1.default.existsSync(searchDirectory) && fs_1.default.statSync(searchDirectory).isDirectory())) {
|
|
59
51
|
return null;
|
|
60
52
|
}
|
|
61
|
-
for (const filename of Constant.mainEntryFilenames) {
|
|
62
|
-
const filepath =
|
|
63
|
-
if (
|
|
53
|
+
for (const filename of Constant_1.Constant.mainEntryFilenames) {
|
|
54
|
+
const filepath = path_1.default.join(searchDirectory, filename);
|
|
55
|
+
if (fs_1.default.existsSync(filepath) && fs_1.default.statSync(filepath).isFile()) {
|
|
64
56
|
return filepath;
|
|
65
57
|
}
|
|
66
58
|
}
|
|
67
59
|
return null;
|
|
68
60
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (!(fs.existsSync(searchDirectory) && fs.statSync(searchDirectory).isDirectory())) {
|
|
61
|
+
static findEntryHTMLFilepath(searchDirectory) {
|
|
62
|
+
if (!(fs_1.default.existsSync(searchDirectory) && fs_1.default.statSync(searchDirectory).isDirectory())) {
|
|
72
63
|
return null;
|
|
73
64
|
}
|
|
74
|
-
const filepath =
|
|
75
|
-
if (
|
|
65
|
+
const filepath = path_1.default.join(searchDirectory, "index.html");
|
|
66
|
+
if (fs_1.default.existsSync(filepath) && fs_1.default.statSync(filepath).isFile()) {
|
|
76
67
|
return filepath;
|
|
77
68
|
}
|
|
78
69
|
return null;
|
|
79
70
|
}
|
|
80
71
|
}
|
|
72
|
+
exports.ConfigEntryDescriptorsFactory = ConfigEntryDescriptorsFactory;
|
|
73
|
+
//# sourceMappingURL=ConfigEntryDescriptorsFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE;YAC3D,OAAO,QAAQ,CAAC;SACnB;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AApED,sEAoEC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
import type { EntryDescriptor } from "../type";
|
|
3
|
+
interface HTMLWebpackPluginsFactoryOptions {
|
|
4
|
+
configEntryDescriptors: EntryDescriptor[];
|
|
5
|
+
}
|
|
6
|
+
export declare class HTMLWebpackPluginsFactory {
|
|
7
|
+
static generate({ configEntryDescriptors }: HTMLWebpackPluginsFactoryOptions): webpack.Plugin[];
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HTMLWebpackPluginsFactory = void 0;
|
|
4
|
+
const Plugin_1 = require("./Plugin");
|
|
5
|
+
class HTMLWebpackPluginsFactory {
|
|
6
|
+
static generate({ configEntryDescriptors }) {
|
|
7
|
+
const htmlPlugins = [];
|
|
8
|
+
for (const { name, entryPath, htmlPath } of configEntryDescriptors) {
|
|
9
|
+
if (htmlPath !== undefined) {
|
|
10
|
+
const plugin = Plugin_1.Plugin.fileOutput.html({
|
|
11
|
+
entry: { name, entryPath, htmlPath },
|
|
12
|
+
});
|
|
13
|
+
htmlPlugins.push(plugin);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return htmlPlugins;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.HTMLWebpackPluginsFactory = HTMLWebpackPluginsFactory;
|
|
20
|
+
//# sourceMappingURL=HTMLWebpackPluginsFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTMLWebpackPluginsFactory.js","sourceRoot":"","sources":["../../../src/WebpackConfigGenerator/HTMLWebpackPluginsFactory.ts"],"names":[],"mappings":";;;AAEA,qCAAgC;AAMhC,MAAa,yBAAyB;IAClC,MAAM,CAAC,QAAQ,CAAC,EAAC,sBAAsB,EAAmC;QACtE,MAAM,WAAW,GAAqB,EAAE,CAAC;QAEzC,KAAK,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC,IAAI,sBAAsB,EAAE;YAC9D,IAAI,QAAQ,KAAK,SAAS,EAAE;gBACxB,MAAM,MAAM,GAAG,eAAM,CAAC,UAAU,CAAC,IAAI,CAAC;oBAClC,KAAK,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAC;iBACrC,CAAC,CAAC;gBACH,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC5B;SACJ;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AAfD,8DAeC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
interface ExtractCssPluginOptions {
|
|
3
|
+
enableProfiling: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Applies CssNano to minimize stylesheets
|
|
7
|
+
* after bundles/chunks are built.
|
|
8
|
+
*/
|
|
9
|
+
export declare function cssMinimizerPlugin(): webpack.WebpackPluginInstance;
|
|
10
|
+
/**
|
|
11
|
+
* Extract output of css transformation pipeline to standalone css files.
|
|
12
|
+
* Must be used with `MiniCssExtractPlugin.loader`, which is included with
|
|
13
|
+
* `Rule.stylesheet({minimize: true})`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function miniCssExtractPlugin({ enableProfiling }: ExtractCssPluginOptions): webpack.WebpackPluginInstance;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
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.miniCssExtractPlugin = exports.cssMinimizerPlugin = void 0;
|
|
7
|
+
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
8
|
+
const css_minimizer_webpack_plugin_1 = __importDefault(require("css-minimizer-webpack-plugin"));
|
|
9
|
+
const WebpackConfigSerializationUtil_1 = require("../WebpackConfigSerializationUtil");
|
|
10
|
+
/**
|
|
11
|
+
* Applies CssNano to minimize stylesheets
|
|
12
|
+
* after bundles/chunks are built.
|
|
13
|
+
*/
|
|
14
|
+
function cssMinimizerPlugin() {
|
|
15
|
+
return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("CssMinimizerWebpackPlugin", css_minimizer_webpack_plugin_1.default);
|
|
16
|
+
}
|
|
17
|
+
exports.cssMinimizerPlugin = cssMinimizerPlugin;
|
|
18
|
+
/**
|
|
19
|
+
* Extract output of css transformation pipeline to standalone css files.
|
|
20
|
+
* Must be used with `MiniCssExtractPlugin.loader`, which is included with
|
|
21
|
+
* `Rule.stylesheet({minimize: true})`.
|
|
22
|
+
*/
|
|
23
|
+
function miniCssExtractPlugin({ enableProfiling }) {
|
|
24
|
+
return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("MiniCssExtractPlugin", mini_css_extract_plugin_1.default, {
|
|
25
|
+
filename: enableProfiling ? "static/css/[name].[contenthash:8].css" : "static/css/[contenthash:8].css",
|
|
26
|
+
// order of css output depends on the order of imports in js,
|
|
27
|
+
// unless all imports in js are sorted (e.g. by alphabetical order),
|
|
28
|
+
// this flag must be set to true to avoid error
|
|
29
|
+
ignoreOrder: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
exports.miniCssExtractPlugin = miniCssExtractPlugin;
|
|
33
|
+
//# sourceMappingURL=css.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/css.plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sFAA2D;AAC3D,gGAAqE;AAErE,sFAAiF;AAMjF;;;GAGG;AACH,SAAgB,kBAAkB;IAC9B,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,2BAA2B,EAAE,sCAAyB,CAAC,CAAC;AACrH,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB,CAAC,EAAC,eAAe,EAA0B;IAC3E,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,iCAAoB,EAAE;QACnG,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC,CAAC,gCAAgC;QACtG,6DAA6D;QAC7D,oEAAoE;QACpE,+CAA+C;QAC/C,WAAW,EAAE,IAAI;KACpB,CAAC,CAAC;AACP,CAAC;AARD,oDAQC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
import type { HTMLEntryDescriptor } from "../../type";
|
|
3
|
+
interface HTMLPluginOptions {
|
|
4
|
+
entry: HTMLEntryDescriptor;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Creates a html file from a template with <script> and <link> injected
|
|
8
|
+
* with the respective hashed output filenames.
|
|
9
|
+
*/
|
|
10
|
+
export declare function htmlPlugin({ entry }: HTMLPluginOptions): webpack.WebpackPluginInstance;
|
|
11
|
+
/**
|
|
12
|
+
* Adds attributes to `<script>` tag inside html file generated by
|
|
13
|
+
* HTMLWebpackPlugin. Used to add `crossorigin="anonymous"`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function scriptTagCrossOriginPlugin(): webpack.WebpackPluginInstance;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
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.scriptTagCrossOriginPlugin = exports.htmlPlugin = void 0;
|
|
7
|
+
const html_webpack_plugin_1 = __importDefault(require("html-webpack-plugin"));
|
|
8
|
+
const script_tag_crossorigin_plugin_1 = require("./script-tag-crossorigin-plugin");
|
|
9
|
+
const WebpackConfigSerializationUtil_1 = require("../WebpackConfigSerializationUtil");
|
|
10
|
+
/**
|
|
11
|
+
* Creates a html file from a template with <script> and <link> injected
|
|
12
|
+
* with the respective hashed output filenames.
|
|
13
|
+
*/
|
|
14
|
+
function htmlPlugin({ entry }) {
|
|
15
|
+
return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("HTMLWebpackPlugin", html_webpack_plugin_1.default, {
|
|
16
|
+
template: entry.htmlPath,
|
|
17
|
+
filename: `${entry.name}.html`,
|
|
18
|
+
chunks: [entry.name],
|
|
19
|
+
minify: {
|
|
20
|
+
collapseBooleanAttributes: true,
|
|
21
|
+
collapseInlineTagWhitespace: true,
|
|
22
|
+
collapseWhitespace: true,
|
|
23
|
+
includeAutoGeneratedTags: false,
|
|
24
|
+
keepClosingSlash: true,
|
|
25
|
+
minifyCSS: true,
|
|
26
|
+
minifyJS: true,
|
|
27
|
+
minifyURLs: true,
|
|
28
|
+
removeAttributeQuotes: true,
|
|
29
|
+
removeComments: true,
|
|
30
|
+
removeEmptyAttributes: true,
|
|
31
|
+
removeRedundantAttributes: true,
|
|
32
|
+
removeScriptTypeAttributes: true,
|
|
33
|
+
removeStyleLinkTypeAttributes: true,
|
|
34
|
+
removeTagWhitespace: true,
|
|
35
|
+
useShortDoctype: true,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
exports.htmlPlugin = htmlPlugin;
|
|
40
|
+
/**
|
|
41
|
+
* Adds attributes to `<script>` tag inside html file generated by
|
|
42
|
+
* HTMLWebpackPlugin. Used to add `crossorigin="anonymous"`.
|
|
43
|
+
*/
|
|
44
|
+
function scriptTagCrossOriginPlugin() {
|
|
45
|
+
return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("ScriptTagCrossOriginPlugin", script_tag_crossorigin_plugin_1.ScriptTagCrossOriginPlugin);
|
|
46
|
+
}
|
|
47
|
+
exports.scriptTagCrossOriginPlugin = scriptTagCrossOriginPlugin;
|
|
48
|
+
//# sourceMappingURL=html.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/html.plugin.ts"],"names":[],"mappings":";;;;;;AAAA,8EAAoD;AACpD,mFAA2E;AAG3E,sFAAiF;AAMjF;;;GAGG;AACH,SAAgB,UAAU,CAAC,EAAC,KAAK,EAAoB;IACjD,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,mBAAmB,EAAE,6BAAiB,EAAE;QAC7F,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,QAAQ,EAAE,GAAG,KAAK,CAAC,IAAI,OAAO;QAC9B,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;QACpB,MAAM,EAAE;YACJ,yBAAyB,EAAE,IAAI;YAC/B,2BAA2B,EAAE,IAAI;YACjC,kBAAkB,EAAE,IAAI;YACxB,wBAAwB,EAAE,KAAK;YAC/B,gBAAgB,EAAE,IAAI;YACtB,SAAS,EAAE,IAAI;YACf,QAAQ,EAAE,IAAI;YACd,UAAU,EAAE,IAAI;YAChB,qBAAqB,EAAE,IAAI;YAC3B,cAAc,EAAE,IAAI;YACpB,qBAAqB,EAAE,IAAI;YAC3B,yBAAyB,EAAE,IAAI;YAC/B,0BAA0B,EAAE,IAAI;YAChC,6BAA6B,EAAE,IAAI;YACnC,mBAAmB,EAAE,IAAI;YACzB,eAAe,EAAE,IAAI;SACxB;KACJ,CAAC,CAAC;AACP,CAAC;AAxBD,gCAwBC;AAED;;;GAGG;AACH,SAAgB,0BAA0B;IACtC,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,4BAA4B,EAAE,0DAA0B,CAAC,CAAC;AACvH,CAAC;AAFD,gEAEC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { cssMinimizerPlugin, miniCssExtractPlugin } from "./css.plugin";
|
|
2
|
+
import { scriptTagCrossOriginPlugin, htmlPlugin } from "./html.plugin";
|
|
3
|
+
import { ignoreMomentLocalePlugin } from "./moment.plugin";
|
|
4
|
+
import { reactRefreshPlugin, terserPlugin } from "./ts.plugin";
|
|
5
|
+
import { webpackDefinePlugin, webpackProgressPlugin } from "./webpack.plugin";
|
|
6
|
+
/**
|
|
7
|
+
* Static factories to create \`webpack.config#plugins\` items.
|
|
8
|
+
*
|
|
9
|
+
* Plugins with similar functionality are grouped under a js object (as a namespace).
|
|
10
|
+
*/
|
|
11
|
+
export declare class Plugin {
|
|
12
|
+
static readonly scriptTagCrossOriginPlugin: typeof scriptTagCrossOriginPlugin;
|
|
13
|
+
static readonly ignoreMomentLocale: typeof ignoreMomentLocalePlugin;
|
|
14
|
+
static readonly reactRefresh: typeof reactRefreshPlugin;
|
|
15
|
+
static readonly fileOutput: {
|
|
16
|
+
html: typeof htmlPlugin;
|
|
17
|
+
miniCssExtract: typeof miniCssExtractPlugin;
|
|
18
|
+
};
|
|
19
|
+
static readonly minimizer: {
|
|
20
|
+
terser: typeof terserPlugin;
|
|
21
|
+
css: typeof cssMinimizerPlugin;
|
|
22
|
+
};
|
|
23
|
+
static readonly webpack: {
|
|
24
|
+
progress: typeof webpackProgressPlugin;
|
|
25
|
+
define: typeof webpackDefinePlugin;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Plugin = void 0;
|
|
4
|
+
const css_plugin_1 = require("./css.plugin");
|
|
5
|
+
const html_plugin_1 = require("./html.plugin");
|
|
6
|
+
const moment_plugin_1 = require("./moment.plugin");
|
|
7
|
+
const ts_plugin_1 = require("./ts.plugin");
|
|
8
|
+
const webpack_plugin_1 = require("./webpack.plugin");
|
|
9
|
+
/**
|
|
10
|
+
* Static factories to create \`webpack.config#plugins\` items.
|
|
11
|
+
*
|
|
12
|
+
* Plugins with similar functionality are grouped under a js object (as a namespace).
|
|
13
|
+
*/
|
|
14
|
+
class Plugin {
|
|
15
|
+
}
|
|
16
|
+
exports.Plugin = Plugin;
|
|
17
|
+
Plugin.scriptTagCrossOriginPlugin = html_plugin_1.scriptTagCrossOriginPlugin;
|
|
18
|
+
Plugin.ignoreMomentLocale = moment_plugin_1.ignoreMomentLocalePlugin;
|
|
19
|
+
Plugin.reactRefresh = ts_plugin_1.reactRefreshPlugin;
|
|
20
|
+
Plugin.fileOutput = {
|
|
21
|
+
html: html_plugin_1.htmlPlugin,
|
|
22
|
+
miniCssExtract: css_plugin_1.miniCssExtractPlugin,
|
|
23
|
+
};
|
|
24
|
+
Plugin.minimizer = {
|
|
25
|
+
terser: ts_plugin_1.terserPlugin,
|
|
26
|
+
css: css_plugin_1.cssMinimizerPlugin,
|
|
27
|
+
};
|
|
28
|
+
Plugin.webpack = {
|
|
29
|
+
progress: webpack_plugin_1.webpackProgressPlugin,
|
|
30
|
+
define: webpack_plugin_1.webpackDefinePlugin,
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/index.ts"],"names":[],"mappings":";;;AAAA,6CAAsE;AACtE,+CAAqE;AACrE,mDAAyD;AACzD,2CAA6D;AAC7D,qDAA4E;AAE5E;;;;GAIG;AACH,MAAa,MAAM;;AAAnB,wBAqBC;AApBmB,iCAA0B,GAAG,wCAA0B,CAAC;AAExD,yBAAkB,GAAG,wCAAwB,CAAC;AAE9C,mBAAY,GAAG,8BAAkB,CAAC;AAElC,iBAAU,GAAG;IACzB,IAAI,EAAE,wBAAU;IAChB,cAAc,EAAE,iCAAoB;CACvC,CAAC;AAEc,gBAAS,GAAG;IACxB,MAAM,EAAE,wBAAY;IACpB,GAAG,EAAE,+BAAkB;CAC1B,CAAC;AAEc,cAAO,GAAG;IACtB,QAAQ,EAAE,sCAAqB;IAC/B,MAAM,EAAE,oCAAmB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import webpack from "webpack";
|
|
2
|
+
/**
|
|
3
|
+
* Prevents moment locales from being bundled by importing moment
|
|
4
|
+
* (moment by default imports all locales)
|
|
5
|
+
* and helps reduce the final bundle size.
|
|
6
|
+
*
|
|
7
|
+
* To include a locale, it must be explicitly imported
|
|
8
|
+
* (preferably at the entry file).
|
|
9
|
+
*/
|
|
10
|
+
export declare function ignoreMomentLocalePlugin(): webpack.WebpackPluginInstance;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.ignoreMomentLocalePlugin = void 0;
|
|
7
|
+
const webpack_1 = __importDefault(require("webpack"));
|
|
8
|
+
const WebpackConfigSerializationUtil_1 = require("../WebpackConfigSerializationUtil");
|
|
4
9
|
/**
|
|
5
10
|
* Prevents moment locales from being bundled by importing moment
|
|
6
11
|
* (moment by default imports all locales)
|
|
@@ -9,8 +14,8 @@ import {WebpackConfigSerializationUtil} from "../WebpackConfigSerializationUtil"
|
|
|
9
14
|
* To include a locale, it must be explicitly imported
|
|
10
15
|
* (preferably at the entry file).
|
|
11
16
|
*/
|
|
12
|
-
|
|
13
|
-
return WebpackConfigSerializationUtil.serializablePlugin("webpack.IgnorePlugin",
|
|
17
|
+
function ignoreMomentLocalePlugin() {
|
|
18
|
+
return WebpackConfigSerializationUtil_1.WebpackConfigSerializationUtil.serializablePlugin("webpack.IgnorePlugin", webpack_1.default.IgnorePlugin, {
|
|
14
19
|
// check dependency-request against the provided regex,
|
|
15
20
|
// and exclude resource from final bundle if matched;
|
|
16
21
|
// e.g. `/^\.\/locale$/` matches the dependency-request `require("./locale/" + name)`
|
|
@@ -20,3 +25,5 @@ export function ignoreMomentLocalePlugin(): webpack.WebpackPluginInstance {
|
|
|
20
25
|
contextRegExp: /moment$/,
|
|
21
26
|
});
|
|
22
27
|
}
|
|
28
|
+
exports.ignoreMomentLocalePlugin = ignoreMomentLocalePlugin;
|
|
29
|
+
//# sourceMappingURL=moment.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moment.plugin.js","sourceRoot":"","sources":["../../../../src/WebpackConfigGenerator/Plugin/moment.plugin.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA8B;AAC9B,sFAAiF;AAEjF;;;;;;;GAOG;AACH,SAAgB,wBAAwB;IACpC,OAAO,+DAA8B,CAAC,kBAAkB,CAAC,sBAAsB,EAAE,iBAAO,CAAC,YAAY,EAAE;QACnG,uDAAuD;QACvD,qDAAqD;QACrD,qFAAqF;QACrF,cAAc,EAAE,cAAc;QAC9B,wDAAwD;QACxD,0GAA0G;QAC1G,aAAa,EAAE,SAAS;KAC3B,CAAC,CAAC;AACP,CAAC;AAVD,4DAUC"}
|