@modern-js/app-tools 2.8.1-alpha.3 → 2.9.0
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/CHANGELOG.md +44 -0
- package/dist/cjs/analyze/templates.js +0 -1
- package/dist/esm/analyze/templates.js +1 -1
- package/dist/esm-node/analyze/templates.js +0 -1
- package/package.json +24 -24
- package/dist/js/modern/analyze/constants.js +0 -56
- package/dist/js/modern/analyze/generateCode.js +0 -247
- package/dist/js/modern/analyze/getBundleEntry.js +0 -71
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +0 -220
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +0 -216
- package/dist/js/modern/analyze/getClientRoutes/index.js +0 -6
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -31
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -109
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -115
- package/dist/js/modern/analyze/getServerRoutes.js +0 -178
- package/dist/js/modern/analyze/index.js +0 -333
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -42
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/modern/analyze/nestedRoutes.js +0 -186
- package/dist/js/modern/analyze/templates.js +0 -328
- package/dist/js/modern/analyze/utils.js +0 -141
- package/dist/js/modern/builder/builder-rspack/index.js +0 -8
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +0 -41
- package/dist/js/modern/builder/builder-webpack/index.js +0 -93
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -116
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/modern/builder/generator/createBuilderOptions.js +0 -24
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +0 -39
- package/dist/js/modern/builder/generator/getBuilderTargets.js +0 -21
- package/dist/js/modern/builder/generator/index.js +0 -53
- package/dist/js/modern/builder/index.js +0 -39
- package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +0 -219
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -27
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -34
- package/dist/js/modern/builder/shared/createCopyPattern.js +0 -46
- package/dist/js/modern/builder/shared/index.js +0 -3
- package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/commands/build.js +0 -91
- package/dist/js/modern/commands/deploy.js +0 -28
- package/dist/js/modern/commands/dev.js +0 -109
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -38
- package/dist/js/modern/commands/serve.js +0 -54
- package/dist/js/modern/config/default.js +0 -175
- package/dist/js/modern/config/index.js +0 -3
- package/dist/js/modern/config/initialize/index.js +0 -12
- package/dist/js/modern/config/initialize/inits.js +0 -154
- package/dist/js/modern/config/legacy/createHtmlConfig.js +0 -35
- package/dist/js/modern/config/legacy/createOutputConfig.js +0 -68
- package/dist/js/modern/config/legacy/createSourceConfig.js +0 -39
- package/dist/js/modern/config/legacy/createToolsConfig.js +0 -42
- package/dist/js/modern/config/legacy/index.js +0 -51
- package/dist/js/modern/defineConfig.js +0 -27
- package/dist/js/modern/exports/server.js +0 -4
- package/dist/js/modern/hooks.js +0 -35
- package/dist/js/modern/index.js +0 -221
- package/dist/js/modern/initialize/index.js +0 -132
- package/dist/js/modern/locale/en.js +0 -36
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -36
- package/dist/js/modern/schema/Schema.js +0 -40
- package/dist/js/modern/schema/index.js +0 -88
- package/dist/js/modern/schema/legacy.js +0 -148
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +0 -1
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +0 -3
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +0 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/modern/utils/config.js +0 -128
- package/dist/js/modern/utils/createServer.js +0 -75
- package/dist/js/modern/utils/env.js +0 -15
- package/dist/js/modern/utils/generateWatchFiles.js +0 -55
- package/dist/js/modern/utils/getSelectedEntries.js +0 -58
- package/dist/js/modern/utils/getServerInternalPlugins.js +0 -58
- package/dist/js/modern/utils/language.js +0 -8
- package/dist/js/modern/utils/printInstructions.js +0 -31
- package/dist/js/modern/utils/restart.js +0 -44
- package/dist/js/modern/utils/routes.js +0 -30
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -100
- package/dist/js/node/analyze/generateCode.js +0 -271
- package/dist/js/node/analyze/getBundleEntry.js +0 -95
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +0 -242
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +0 -238
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -30
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -58
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -131
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -144
- package/dist/js/node/analyze/getServerRoutes.js +0 -196
- package/dist/js/node/analyze/index.js +0 -340
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -71
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -36
- package/dist/js/node/analyze/nestedRoutes.js +0 -213
- package/dist/js/node/analyze/templates.js +0 -359
- package/dist/js/node/analyze/utils.js +0 -172
- package/dist/js/node/builder/builder-rspack/index.js +0 -31
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/node/builder/builder-webpack/index.js +0 -118
- package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -140
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +0 -17
- package/dist/js/node/builder/generator/createBuilderOptions.js +0 -47
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +0 -60
- package/dist/js/node/builder/generator/getBuilderTargets.js +0 -39
- package/dist/js/node/builder/generator/index.js +0 -82
- package/dist/js/node/builder/index.js +0 -68
- package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +0 -245
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -50
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -57
- package/dist/js/node/builder/shared/createCopyPattern.js +0 -75
- package/dist/js/node/builder/shared/index.js +0 -19
- package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +0 -28
- package/dist/js/node/builder/shared/types.js +0 -15
- package/dist/js/node/commands/build.js +0 -112
- package/dist/js/node/commands/deploy.js +0 -51
- package/dist/js/node/commands/dev.js +0 -126
- package/dist/js/node/commands/index.js +0 -19
- package/dist/js/node/commands/inspect.js +0 -61
- package/dist/js/node/commands/serve.js +0 -83
- package/dist/js/node/config/default.js +0 -197
- package/dist/js/node/config/index.js +0 -19
- package/dist/js/node/config/initialize/index.js +0 -35
- package/dist/js/node/config/initialize/inits.js +0 -177
- package/dist/js/node/config/legacy/createHtmlConfig.js +0 -58
- package/dist/js/node/config/legacy/createOutputConfig.js +0 -91
- package/dist/js/node/config/legacy/createSourceConfig.js +0 -62
- package/dist/js/node/config/legacy/createToolsConfig.js +0 -65
- package/dist/js/node/config/legacy/index.js +0 -75
- package/dist/js/node/defineConfig.js +0 -49
- package/dist/js/node/exports/server.js +0 -27
- package/dist/js/node/hooks.js +0 -54
- package/dist/js/node/index.js +0 -245
- package/dist/js/node/initialize/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -59
- package/dist/js/node/locale/index.js +0 -33
- package/dist/js/node/locale/zh.js +0 -59
- package/dist/js/node/schema/Schema.js +0 -63
- package/dist/js/node/schema/index.js +0 -118
- package/dist/js/node/schema/legacy.js +0 -169
- package/dist/js/node/types/config/deploy.js +0 -15
- package/dist/js/node/types/config/dev.js +0 -15
- package/dist/js/node/types/config/experiments.js +0 -15
- package/dist/js/node/types/config/html.js +0 -15
- package/dist/js/node/types/config/index.js +0 -17
- package/dist/js/node/types/config/output.js +0 -15
- package/dist/js/node/types/config/performance.js +0 -15
- package/dist/js/node/types/config/security.js +0 -15
- package/dist/js/node/types/config/source.js +0 -15
- package/dist/js/node/types/config/tools.js +0 -15
- package/dist/js/node/types/hooks.js +0 -15
- package/dist/js/node/types/index.js +0 -19
- package/dist/js/node/types/legacyConfig/deploy.js +0 -15
- package/dist/js/node/types/legacyConfig/dev.js +0 -15
- package/dist/js/node/types/legacyConfig/index.js +0 -15
- package/dist/js/node/types/legacyConfig/output.js +0 -15
- package/dist/js/node/types/legacyConfig/source.js +0 -15
- package/dist/js/node/types/legacyConfig/tools.js +0 -15
- package/dist/js/node/types/utils.js +0 -15
- package/dist/js/node/utils/config.js +0 -153
- package/dist/js/node/utils/createServer.js +0 -106
- package/dist/js/node/utils/env.js +0 -38
- package/dist/js/node/utils/generateWatchFiles.js +0 -85
- package/dist/js/node/utils/getSelectedEntries.js +0 -81
- package/dist/js/node/utils/getServerInternalPlugins.js +0 -79
- package/dist/js/node/utils/language.js +0 -31
- package/dist/js/node/utils/printInstructions.js +0 -54
- package/dist/js/node/utils/restart.js +0 -67
- package/dist/js/node/utils/routes.js +0 -59
- package/dist/js/node/utils/types.js +0 -15
- package/dist/js/treeshaking/analyze/constants.js +0 -42
- package/dist/js/treeshaking/analyze/generateCode.js +0 -485
- package/dist/js/treeshaking/analyze/getBundleEntry.js +0 -62
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +0 -233
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +0 -231
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +0 -3
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -23
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +0 -107
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +0 -302
- package/dist/js/treeshaking/analyze/getServerRoutes.js +0 -224
- package/dist/js/treeshaking/analyze/index.js +0 -702
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -47
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -13
- package/dist/js/treeshaking/analyze/nestedRoutes.js +0 -409
- package/dist/js/treeshaking/analyze/templates.js +0 -465
- package/dist/js/treeshaking/analyze/utils.js +0 -374
- package/dist/js/treeshaking/builder/builder-rspack/index.js +0 -6
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +0 -64
- package/dist/js/treeshaking/builder/builder-webpack/index.js +0 -301
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +0 -346
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +0 -1
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +0 -41
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +0 -70
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +0 -16
- package/dist/js/treeshaking/builder/generator/index.js +0 -199
- package/dist/js/treeshaking/builder/index.js +0 -175
- package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +0 -300
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -110
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -72
- package/dist/js/treeshaking/builder/shared/createCopyPattern.js +0 -40
- package/dist/js/treeshaking/builder/shared/index.js +0 -3
- package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +0 -5
- package/dist/js/treeshaking/builder/shared/types.js +0 -1
- package/dist/js/treeshaking/commands/build.js +0 -291
- package/dist/js/treeshaking/commands/deploy.js +0 -154
- package/dist/js/treeshaking/commands/dev.js +0 -301
- package/dist/js/treeshaking/commands/index.js +0 -3
- package/dist/js/treeshaking/commands/inspect.js +0 -149
- package/dist/js/treeshaking/commands/serve.js +0 -199
- package/dist/js/treeshaking/config/default.js +0 -210
- package/dist/js/treeshaking/config/index.js +0 -3
- package/dist/js/treeshaking/config/initialize/index.js +0 -10
- package/dist/js/treeshaking/config/initialize/inits.js +0 -211
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/legacy/createOutputConfig.js +0 -41
- package/dist/js/treeshaking/config/legacy/createSourceConfig.js +0 -42
- package/dist/js/treeshaking/config/legacy/createToolsConfig.js +0 -23
- package/dist/js/treeshaking/config/legacy/index.js +0 -38
- package/dist/js/treeshaking/defineConfig.js +0 -61
- package/dist/js/treeshaking/exports/server.js +0 -2
- package/dist/js/treeshaking/hooks.js +0 -29
- package/dist/js/treeshaking/index.js +0 -713
- package/dist/js/treeshaking/initialize/index.js +0 -284
- package/dist/js/treeshaking/locale/en.js +0 -38
- package/dist/js/treeshaking/locale/index.js +0 -9
- package/dist/js/treeshaking/locale/zh.js +0 -38
- package/dist/js/treeshaking/schema/Schema.js +0 -273
- package/dist/js/treeshaking/schema/index.js +0 -181
- package/dist/js/treeshaking/schema/legacy.js +0 -337
- package/dist/js/treeshaking/types/config/deploy.js +0 -1
- package/dist/js/treeshaking/types/config/dev.js +0 -1
- package/dist/js/treeshaking/types/config/experiments.js +0 -1
- package/dist/js/treeshaking/types/config/html.js +0 -1
- package/dist/js/treeshaking/types/config/index.js +0 -1
- package/dist/js/treeshaking/types/config/output.js +0 -1
- package/dist/js/treeshaking/types/config/performance.js +0 -1
- package/dist/js/treeshaking/types/config/security.js +0 -1
- package/dist/js/treeshaking/types/config/source.js +0 -1
- package/dist/js/treeshaking/types/config/tools.js +0 -1
- package/dist/js/treeshaking/types/hooks.js +0 -1
- package/dist/js/treeshaking/types/index.js +0 -3
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/output.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -1
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -1
- package/dist/js/treeshaking/types/utils.js +0 -1
- package/dist/js/treeshaking/utils/config.js +0 -302
- package/dist/js/treeshaking/utils/createServer.js +0 -258
- package/dist/js/treeshaking/utils/env.js +0 -13
- package/dist/js/treeshaking/utils/generateWatchFiles.js +0 -214
- package/dist/js/treeshaking/utils/getSelectedEntries.js +0 -186
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +0 -210
- package/dist/js/treeshaking/utils/language.js +0 -6
- package/dist/js/treeshaking/utils/printInstructions.js +0 -152
- package/dist/js/treeshaking/utils/restart.js +0 -187
- package/dist/js/treeshaking/utils/routes.js +0 -153
- package/dist/js/treeshaking/utils/types.js +0 -1
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
function _objectSpread(target) {
|
|
15
|
-
for(var i = 1; i < arguments.length; i++){
|
|
16
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
17
|
-
var ownKeys = Object.keys(source);
|
|
18
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
19
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
20
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
21
|
-
}));
|
|
22
|
-
}
|
|
23
|
-
ownKeys.forEach(function(key) {
|
|
24
|
-
_defineProperty(target, key, source[key]);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return target;
|
|
28
|
-
}
|
|
29
|
-
function ownKeys(object, enumerableOnly) {
|
|
30
|
-
var keys = Object.keys(object);
|
|
31
|
-
if (Object.getOwnPropertySymbols) {
|
|
32
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
-
if (enumerableOnly) {
|
|
34
|
-
symbols = symbols.filter(function(sym) {
|
|
35
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
keys.push.apply(keys, symbols);
|
|
39
|
-
}
|
|
40
|
-
return keys;
|
|
41
|
-
}
|
|
42
|
-
function _objectSpreadProps(target, source) {
|
|
43
|
-
source = source != null ? source : {};
|
|
44
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
-
} else {
|
|
47
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return target;
|
|
52
|
-
}
|
|
53
|
-
import { mergeBuilderConfig } from "@modern-js/builder-shared";
|
|
54
|
-
import { getEntryOptions } from "@modern-js/utils";
|
|
55
|
-
import HtmlWebpackPlugin from "@modern-js/builder-webpack-provider/html-webpack-plugin";
|
|
56
|
-
import { template as lodashTemplate } from "@modern-js/utils/lodash";
|
|
57
|
-
import { HtmlAsyncChunkPlugin } from "../bundlerPlugins/HtmlAsyncChunkPlugin";
|
|
58
|
-
import { BottomTemplatePlugin } from "../bundlerPlugins/HtmlBottomTemplate";
|
|
59
|
-
var isStreamingSSR = function(userConfig) {
|
|
60
|
-
var isStreaming = function(ssr) {
|
|
61
|
-
return ssr && typeof ssr === "object" && ssr.mode === "stream";
|
|
62
|
-
};
|
|
63
|
-
var server = userConfig.server;
|
|
64
|
-
if (isStreaming(server.ssr)) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && typeof server.ssrByEntries === "object") {
|
|
68
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
69
|
-
try {
|
|
70
|
-
for(var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
71
|
-
var name = _step.value;
|
|
72
|
-
if (isStreaming(server.ssrByEntries[name])) {
|
|
73
|
-
return true;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} catch (err) {
|
|
77
|
-
_didIteratorError = true;
|
|
78
|
-
_iteratorError = err;
|
|
79
|
-
} finally{
|
|
80
|
-
try {
|
|
81
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
82
|
-
_iterator.return();
|
|
83
|
-
}
|
|
84
|
-
} finally{
|
|
85
|
-
if (_didIteratorError) {
|
|
86
|
-
throw _iteratorError;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
};
|
|
93
|
-
var builderPluginAdapterModern = function(options) {
|
|
94
|
-
return {
|
|
95
|
-
name: "builder-plugin-adapter-modern",
|
|
96
|
-
setup: function setup(api) {
|
|
97
|
-
var isHtmlEnabled = function isHtmlEnabled(config, target) {
|
|
98
|
-
var _config_tools;
|
|
99
|
-
return ((_config_tools = config.tools) === null || _config_tools === void 0 ? void 0 : _config_tools.htmlPlugin) !== false && target !== "node" && target !== "service-worker" && target !== "web-worker";
|
|
100
|
-
};
|
|
101
|
-
var normalizedConfig = options.normalizedConfig, appContext = options.appContext;
|
|
102
|
-
api.modifyBuilderConfig(function(config) {
|
|
103
|
-
if (isStreamingSSR(normalizedConfig)) {
|
|
104
|
-
return mergeBuilderConfig(config, {
|
|
105
|
-
html: {
|
|
106
|
-
inject: "body"
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
return config;
|
|
111
|
-
});
|
|
112
|
-
api.modifyBundlerChain(function(chain, param) {
|
|
113
|
-
var target = param.target, CHAIN_ID = param.CHAIN_ID, isProd = param.isProd;
|
|
114
|
-
var builderConfig = api.getNormalizedConfig();
|
|
115
|
-
if (target === "node") {
|
|
116
|
-
chain.name("server");
|
|
117
|
-
} else if (target === "service-worker") {
|
|
118
|
-
chain.name("service-worker");
|
|
119
|
-
} else if (target === "web-worker") {
|
|
120
|
-
chain.name("worker");
|
|
121
|
-
} else if (target === "modern-web") {
|
|
122
|
-
chain.name("modern");
|
|
123
|
-
} else {
|
|
124
|
-
chain.name("client");
|
|
125
|
-
}
|
|
126
|
-
if (target === "node" || target === "service-worker") {
|
|
127
|
-
applyNodeCompat(target, chain, normalizedConfig, isProd);
|
|
128
|
-
}
|
|
129
|
-
if (isHtmlEnabled(builderConfig, target)) {
|
|
130
|
-
applyBottomHtmlPlugin({
|
|
131
|
-
api: api,
|
|
132
|
-
chain: chain,
|
|
133
|
-
modernConfig: normalizedConfig,
|
|
134
|
-
appContext: appContext,
|
|
135
|
-
CHAIN_ID: CHAIN_ID
|
|
136
|
-
});
|
|
137
|
-
applyAsyncChunkHtmlPlugin({
|
|
138
|
-
chain: chain,
|
|
139
|
-
modernConfig: normalizedConfig,
|
|
140
|
-
CHAIN_ID: CHAIN_ID
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
if (target !== "node" && target !== "web-worker" && target !== "service-worker") {
|
|
144
|
-
var bareServerModuleReg = /\.(server|node)\.[tj]sx?$/;
|
|
145
|
-
chain.module.rule(CHAIN_ID.RULE.JS).exclude.add(bareServerModuleReg);
|
|
146
|
-
chain.module.rule("bare-server-module").test(bareServerModuleReg).use("server-module-loader").loader(require.resolve("../loaders/serverModuleLoader"));
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
applyCallbacks(api, options);
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
};
|
|
153
|
-
function applyCallbacks(api, options) {
|
|
154
|
-
options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
|
|
155
|
-
options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
|
|
156
|
-
options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
|
|
157
|
-
options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
|
|
158
|
-
options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
|
|
159
|
-
options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
|
|
160
|
-
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
161
|
-
options.onExit && api.onExit(options.onExit);
|
|
162
|
-
}
|
|
163
|
-
function applyBottomHtmlPlugin(param) {
|
|
164
|
-
var api = param.api, chain = param.chain, modernConfig = param.modernConfig, appContext = param.appContext, CHAIN_ID = param.CHAIN_ID;
|
|
165
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
166
|
-
try {
|
|
167
|
-
var _loop = function() {
|
|
168
|
-
var entryName = _step.value;
|
|
169
|
-
var baseTemplateParams = _objectSpread({
|
|
170
|
-
entryName: entryName,
|
|
171
|
-
title: getEntryOptions(entryName, modernConfig.html.title, modernConfig.html.titleByEntries, appContext.packageName),
|
|
172
|
-
mountId: modernConfig.html.mountId
|
|
173
|
-
}, getEntryOptions(entryName, modernConfig.html.templateParameters, modernConfig.html.templateParametersByEntries, appContext.packageName));
|
|
174
|
-
chain.plugin("".concat(CHAIN_ID.PLUGIN.HTML, "-").concat(entryName)).tap(function(args) {
|
|
175
|
-
return [
|
|
176
|
-
_objectSpreadProps(_objectSpread({}, args[0] || {}), {
|
|
177
|
-
__internal__: true,
|
|
178
|
-
bottomTemplate: appContext.htmlTemplates["__".concat(entryName, "-bottom__")] && lodashTemplate(appContext.htmlTemplates["__".concat(entryName, "-bottom__")])(baseTemplateParams)
|
|
179
|
-
})
|
|
180
|
-
];
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
for(var _iterator = Object.keys(api.context.entry)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
184
|
-
} catch (err) {
|
|
185
|
-
_didIteratorError = true;
|
|
186
|
-
_iteratorError = err;
|
|
187
|
-
} finally{
|
|
188
|
-
try {
|
|
189
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
190
|
-
_iterator.return();
|
|
191
|
-
}
|
|
192
|
-
} finally{
|
|
193
|
-
if (_didIteratorError) {
|
|
194
|
-
throw _iteratorError;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(BottomTemplatePlugin, [
|
|
199
|
-
HtmlWebpackPlugin
|
|
200
|
-
]);
|
|
201
|
-
}
|
|
202
|
-
function applyAsyncChunkHtmlPlugin(param) {
|
|
203
|
-
var chain = param.chain, modernConfig = param.modernConfig, CHAIN_ID = param.CHAIN_ID;
|
|
204
|
-
if (isStreamingSSR(modernConfig)) {
|
|
205
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(HtmlAsyncChunkPlugin, [
|
|
206
|
-
HtmlWebpackPlugin
|
|
207
|
-
]);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function applyNodeCompat(target, chain, modernConfig, isProd) {
|
|
211
|
-
var filterEntriesBySSRConfig = function filterEntriesBySSRConfig(isProd2, chain2, serverConfig, outputConfig) {
|
|
212
|
-
var _outputConfig_ssg;
|
|
213
|
-
var entries = chain2.entryPoints.entries();
|
|
214
|
-
if (isProd2 && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (_outputConfig_ssg = outputConfig.ssg) === null || _outputConfig_ssg === void 0 ? void 0 : _outputConfig_ssg[0]) === "function")) {
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
if (typeof entries === "undefined") {
|
|
218
|
-
throw new Error("No entry found, one of src/routes/layout.tsx, src/App.tsx, src/index.tsx is required");
|
|
219
|
-
}
|
|
220
|
-
var entryNames = Object.keys(entries);
|
|
221
|
-
if (isProd2 && entryNames.length === 1 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
var ssgEntries = [];
|
|
225
|
-
if (isProd2 && (outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg)) {
|
|
226
|
-
var ssg = outputConfig.ssg;
|
|
227
|
-
entryNames.forEach(function(name) {
|
|
228
|
-
if (ssg[name]) {
|
|
229
|
-
ssgEntries.push(name);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
var _ref = serverConfig || {}, ssr = _ref.ssr, ssrByEntries = _ref.ssrByEntries;
|
|
234
|
-
entryNames.forEach(function(name) {
|
|
235
|
-
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]))) {
|
|
236
|
-
chain2.entryPoints.delete(name);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
var nodeExts = [
|
|
241
|
-
".node.js",
|
|
242
|
-
".node.jsx",
|
|
243
|
-
".node.ts",
|
|
244
|
-
".node.tsx",
|
|
245
|
-
".server.js",
|
|
246
|
-
".server.ts",
|
|
247
|
-
".server.ts",
|
|
248
|
-
".server.tsx"
|
|
249
|
-
];
|
|
250
|
-
var webWorkerExts = [
|
|
251
|
-
".worker.js",
|
|
252
|
-
".worker.jsx",
|
|
253
|
-
".worker.ts",
|
|
254
|
-
".worker.tsx"
|
|
255
|
-
];
|
|
256
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
257
|
-
try {
|
|
258
|
-
for(var _iterator = nodeExts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
259
|
-
var ext = _step.value;
|
|
260
|
-
chain.resolve.extensions.prepend(ext);
|
|
261
|
-
}
|
|
262
|
-
} catch (err) {
|
|
263
|
-
_didIteratorError = true;
|
|
264
|
-
_iteratorError = err;
|
|
265
|
-
} finally{
|
|
266
|
-
try {
|
|
267
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
268
|
-
_iterator.return();
|
|
269
|
-
}
|
|
270
|
-
} finally{
|
|
271
|
-
if (_didIteratorError) {
|
|
272
|
-
throw _iteratorError;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
if (target === "service-worker") {
|
|
277
|
-
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
278
|
-
try {
|
|
279
|
-
for(var _iterator1 = webWorkerExts[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
280
|
-
var ext1 = _step1.value;
|
|
281
|
-
chain.resolve.extensions.prepend(ext1);
|
|
282
|
-
}
|
|
283
|
-
} catch (err) {
|
|
284
|
-
_didIteratorError1 = true;
|
|
285
|
-
_iteratorError1 = err;
|
|
286
|
-
} finally{
|
|
287
|
-
try {
|
|
288
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
289
|
-
_iterator1.return();
|
|
290
|
-
}
|
|
291
|
-
} finally{
|
|
292
|
-
if (_didIteratorError1) {
|
|
293
|
-
throw _iteratorError1;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
filterEntriesBySSRConfig(isProd, chain, modernConfig.server, modernConfig.output);
|
|
299
|
-
}
|
|
300
|
-
export { applyCallbacks, builderPluginAdapterModern };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
function _arrayLikeToArray(arr, len) {
|
|
2
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
-
return arr2;
|
|
5
|
-
}
|
|
6
|
-
function _arrayWithoutHoles(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
|
-
}
|
|
9
|
-
function _classCallCheck(instance, Constructor) {
|
|
10
|
-
if (!(instance instanceof Constructor)) {
|
|
11
|
-
throw new TypeError("Cannot call a class as a function");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function _defineProperties(target, props) {
|
|
15
|
-
for(var i = 0; i < props.length; i++){
|
|
16
|
-
var descriptor = props[i];
|
|
17
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
18
|
-
descriptor.configurable = true;
|
|
19
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
20
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
24
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
25
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
26
|
-
return Constructor;
|
|
27
|
-
}
|
|
28
|
-
function _defineProperty(obj, key, value) {
|
|
29
|
-
if (key in obj) {
|
|
30
|
-
Object.defineProperty(obj, key, {
|
|
31
|
-
value: value,
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
obj[key] = value;
|
|
38
|
-
}
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
function _iterableToArray(iter) {
|
|
42
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
43
|
-
}
|
|
44
|
-
function _nonIterableSpread() {
|
|
45
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
46
|
-
}
|
|
47
|
-
function _toConsumableArray(arr) {
|
|
48
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
49
|
-
}
|
|
50
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
51
|
-
if (!o) return;
|
|
52
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
53
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
54
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
55
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
57
|
-
}
|
|
58
|
-
var HtmlAsyncChunkPlugin = /*#__PURE__*/ function() {
|
|
59
|
-
"use strict";
|
|
60
|
-
function HtmlAsyncChunkPlugin(htmlWebpackPlugin) {
|
|
61
|
-
_classCallCheck(this, HtmlAsyncChunkPlugin);
|
|
62
|
-
_defineProperty(this, "name", void 0);
|
|
63
|
-
_defineProperty(this, "htmlWebpackPlugin", void 0);
|
|
64
|
-
this.name = "HtmlAsyncChunkPlugin";
|
|
65
|
-
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
66
|
-
}
|
|
67
|
-
_createClass(HtmlAsyncChunkPlugin, [
|
|
68
|
-
{
|
|
69
|
-
key: "apply",
|
|
70
|
-
value: function apply(compiler) {
|
|
71
|
-
var _this = this;
|
|
72
|
-
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
|
73
|
-
var hooks = _this.htmlWebpackPlugin.getHooks(compilation);
|
|
74
|
-
hooks.alterAssetTagGroups.tap(_this.name, function(assets) {
|
|
75
|
-
var tags = _toConsumableArray(assets.headTags).concat(_toConsumableArray(assets.bodyTags));
|
|
76
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
77
|
-
try {
|
|
78
|
-
for(var _iterator = tags[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
79
|
-
var tag = _step.value;
|
|
80
|
-
if (tag.tagName === "script") {
|
|
81
|
-
var attributes = tag.attributes;
|
|
82
|
-
if (attributes && attributes.defer === true) {
|
|
83
|
-
attributes.async = true;
|
|
84
|
-
delete attributes.defer;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
} catch (err) {
|
|
89
|
-
_didIteratorError = true;
|
|
90
|
-
_iteratorError = err;
|
|
91
|
-
} finally{
|
|
92
|
-
try {
|
|
93
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
94
|
-
_iterator.return();
|
|
95
|
-
}
|
|
96
|
-
} finally{
|
|
97
|
-
if (_didIteratorError) {
|
|
98
|
-
throw _iteratorError;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return assets;
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
]);
|
|
108
|
-
return HtmlAsyncChunkPlugin;
|
|
109
|
-
}();
|
|
110
|
-
export { HtmlAsyncChunkPlugin };
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
function _classCallCheck(instance, Constructor) {
|
|
2
|
-
if (!(instance instanceof Constructor)) {
|
|
3
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _defineProperties(target, props) {
|
|
7
|
-
for(var i = 0; i < props.length; i++){
|
|
8
|
-
var descriptor = props[i];
|
|
9
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
-
descriptor.configurable = true;
|
|
11
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
-
return Constructor;
|
|
19
|
-
}
|
|
20
|
-
function _defineProperty(obj, key, value) {
|
|
21
|
-
if (key in obj) {
|
|
22
|
-
Object.defineProperty(obj, key, {
|
|
23
|
-
value: value,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
obj[key] = value;
|
|
30
|
-
}
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
var BottomTemplatePlugin = /*#__PURE__*/ function() {
|
|
34
|
-
"use strict";
|
|
35
|
-
function BottomTemplatePlugin(htmlWebpackPlugin) {
|
|
36
|
-
_classCallCheck(this, BottomTemplatePlugin);
|
|
37
|
-
_defineProperty(this, "htmlWebpackPlugin", void 0);
|
|
38
|
-
_defineProperty(this, "bottomTemplateReg", /<!--<\?-\s*bottomTemplate\s*\?>-->/);
|
|
39
|
-
_defineProperty(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
|
|
40
|
-
_defineProperty(this, "name", void 0);
|
|
41
|
-
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
|
42
|
-
this.name = "bottom-template";
|
|
43
|
-
}
|
|
44
|
-
_createClass(BottomTemplatePlugin, [
|
|
45
|
-
{
|
|
46
|
-
key: "apply",
|
|
47
|
-
value: function apply(compiler) {
|
|
48
|
-
var _this = this;
|
|
49
|
-
compiler.hooks.compilation.tap(this.name, function(compilation) {
|
|
50
|
-
_this.htmlWebpackPlugin.getHooks(compilation).beforeEmit.tap(_this.name, function(data) {
|
|
51
|
-
var _data_plugin_options;
|
|
52
|
-
if (!((_data_plugin_options = data.plugin.options) === null || _data_plugin_options === void 0 ? void 0 : _data_plugin_options.__internal__)) {
|
|
53
|
-
return data;
|
|
54
|
-
}
|
|
55
|
-
if (_this.bottomTemplateReg.test(data.html)) {
|
|
56
|
-
data.html = data.html.replace(_this.bottomTemplateReg, "");
|
|
57
|
-
var bottomTemplate = data.plugin.options.bottomTemplate;
|
|
58
|
-
if (bottomTemplate) {
|
|
59
|
-
data.html = data.html.replace(_this.bodyRegExp, function(match) {
|
|
60
|
-
return "\n".concat(bottomTemplate, "\n").concat(match);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return data;
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
]);
|
|
70
|
-
return BottomTemplatePlugin;
|
|
71
|
-
}();
|
|
72
|
-
export { BottomTemplatePlugin };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { removeTailSlash } from "@modern-js/utils";
|
|
3
|
-
function createCopyPattern(appContext, config, patternsType, chain) {
|
|
4
|
-
var configDir = path.resolve(appContext.appDirectory, config.source.configDir || "./config");
|
|
5
|
-
var uploadDir = path.posix.join(configDir.replace(/\\/g, "/"), "upload");
|
|
6
|
-
var publicDir = path.posix.join(configDir.replace(/\\/g, "/"), "public");
|
|
7
|
-
var minifiedJsRexExp = /\.min\.js/;
|
|
8
|
-
var info = function(file) {
|
|
9
|
-
return {
|
|
10
|
-
minimized: minifiedJsRexExp.test(file.sourceFilename)
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
if (patternsType === "public") {
|
|
14
|
-
if (!chain) {
|
|
15
|
-
throw new Error("expect get a webpackChain, but receive 'undefined'");
|
|
16
|
-
}
|
|
17
|
-
return {
|
|
18
|
-
info: info,
|
|
19
|
-
from: "**/*",
|
|
20
|
-
to: "public",
|
|
21
|
-
context: publicDir,
|
|
22
|
-
noErrorOnMissing: true,
|
|
23
|
-
transform: function(content, absoluteFrom) {
|
|
24
|
-
if (!/\.html?$/.test(absoluteFrom)) {
|
|
25
|
-
return content;
|
|
26
|
-
}
|
|
27
|
-
return content.toString("utf8").replace(/<%=\s*assetPrefix\s*%>/g, removeTailSlash(chain.output.get("publicPath")));
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
} else {
|
|
31
|
-
return {
|
|
32
|
-
info: info,
|
|
33
|
-
from: "**/*",
|
|
34
|
-
to: "upload",
|
|
35
|
-
context: uploadDir,
|
|
36
|
-
noErrorOnMissing: true
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export { createCopyPattern };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|