@modern-js/app-tools 2.5.0 → 2.5.1-alpha.1
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/dist/cjs/commands/dev.js +6 -0
- package/dist/cjs/commands/serve.js +17 -0
- package/dist/esm/commands/dev.js +6 -0
- package/dist/esm/commands/serve.js +6 -1
- package/dist/esm-node/commands/dev.js +6 -0
- package/dist/esm-node/commands/serve.js +18 -1
- package/dist/js/modern/analyze/constants.js +56 -0
- package/dist/js/modern/analyze/generateCode.js +247 -0
- package/dist/js/modern/analyze/getBundleEntry.js +71 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +220 -0
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +216 -0
- package/dist/js/modern/analyze/getClientRoutes/index.js +6 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +31 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +109 -0
- package/dist/js/modern/analyze/getHtmlTemplate.js +115 -0
- package/dist/js/modern/analyze/getServerRoutes.js +178 -0
- package/dist/js/modern/analyze/index.js +333 -0
- package/dist/js/modern/analyze/isDefaultExportFunction.js +42 -0
- package/dist/js/modern/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/modern/analyze/nestedRoutes.js +186 -0
- package/dist/js/modern/analyze/templates.js +328 -0
- package/dist/js/modern/analyze/utils.js +141 -0
- package/dist/js/modern/builder/builder-rspack/index.js +8 -0
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/js/modern/builder/builder-webpack/index.js +93 -0
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/RouterPlugin.js +116 -0
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
- package/dist/js/modern/builder/generator/getBuilderTargets.js +21 -0
- package/dist/js/modern/builder/generator/index.js +53 -0
- package/dist/js/modern/builder/index.js +39 -0
- package/dist/js/modern/builder/shared/builderPlugins/adapterModern.js +219 -0
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/js/modern/builder/shared/createCopyPattern.js +46 -0
- package/dist/js/modern/builder/shared/index.js +3 -0
- package/dist/js/modern/builder/shared/loaders/serverModuleLoader.js +7 -0
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/commands/build.js +91 -0
- package/dist/js/modern/commands/deploy.js +28 -0
- package/dist/js/modern/commands/dev.js +109 -0
- package/dist/js/modern/commands/index.js +3 -0
- package/dist/js/modern/commands/inspect.js +38 -0
- package/dist/js/modern/commands/serve.js +54 -0
- package/dist/js/modern/config/default.js +175 -0
- package/dist/js/modern/config/index.js +3 -0
- package/dist/js/modern/config/initialize/index.js +12 -0
- package/dist/js/modern/config/initialize/inits.js +154 -0
- package/dist/js/modern/config/legacy/createHtmlConfig.js +35 -0
- package/dist/js/modern/config/legacy/createOutputConfig.js +68 -0
- package/dist/js/modern/config/legacy/createSourceConfig.js +39 -0
- package/dist/js/modern/config/legacy/createToolsConfig.js +42 -0
- package/dist/js/modern/config/legacy/index.js +51 -0
- package/dist/js/modern/defineConfig.js +27 -0
- package/dist/js/modern/exports/server.js +4 -0
- package/dist/js/modern/hooks.js +35 -0
- package/dist/js/modern/index.js +221 -0
- package/dist/js/modern/initialize/index.js +132 -0
- package/dist/js/modern/locale/en.js +36 -0
- package/dist/js/modern/locale/index.js +9 -0
- package/dist/js/modern/locale/zh.js +36 -0
- package/dist/js/modern/schema/Schema.js +40 -0
- package/dist/js/modern/schema/index.js +88 -0
- package/dist/js/modern/schema/legacy.js +148 -0
- 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 +1 -0
- 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 +3 -0
- 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 +128 -0
- package/dist/js/modern/utils/createServer.js +75 -0
- package/dist/js/modern/utils/env.js +15 -0
- package/dist/js/modern/utils/generateWatchFiles.js +55 -0
- package/dist/js/modern/utils/getSelectedEntries.js +58 -0
- package/dist/js/modern/utils/getServerInternalPlugins.js +58 -0
- package/dist/js/modern/utils/language.js +8 -0
- package/dist/js/modern/utils/printInstructions.js +31 -0
- package/dist/js/modern/utils/restart.js +44 -0
- package/dist/js/modern/utils/routes.js +30 -0
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +100 -0
- package/dist/js/node/analyze/generateCode.js +271 -0
- package/dist/js/node/analyze/getBundleEntry.js +95 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +242 -0
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +238 -0
- package/dist/js/node/analyze/getClientRoutes/index.js +30 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +58 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +131 -0
- package/dist/js/node/analyze/getHtmlTemplate.js +144 -0
- package/dist/js/node/analyze/getServerRoutes.js +196 -0
- package/dist/js/node/analyze/index.js +340 -0
- package/dist/js/node/analyze/isDefaultExportFunction.js +71 -0
- package/dist/js/node/analyze/makeLegalIdentifier.js +36 -0
- package/dist/js/node/analyze/nestedRoutes.js +213 -0
- package/dist/js/node/analyze/templates.js +359 -0
- package/dist/js/node/analyze/utils.js +172 -0
- package/dist/js/node/builder/builder-rspack/index.js +31 -0
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/node/builder/builder-webpack/index.js +118 -0
- package/dist/js/node/builder/builder-webpack/webpackPlugins/RouterPlugin.js +140 -0
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
- package/dist/js/node/builder/generator/getBuilderTargets.js +39 -0
- package/dist/js/node/builder/generator/index.js +82 -0
- package/dist/js/node/builder/index.js +68 -0
- package/dist/js/node/builder/shared/builderPlugins/adapterModern.js +245 -0
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +50 -0
- package/dist/js/node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +57 -0
- package/dist/js/node/builder/shared/createCopyPattern.js +75 -0
- package/dist/js/node/builder/shared/index.js +19 -0
- package/dist/js/node/builder/shared/loaders/serverModuleLoader.js +28 -0
- package/dist/js/node/builder/shared/types.js +15 -0
- package/dist/js/node/commands/build.js +112 -0
- package/dist/js/node/commands/deploy.js +51 -0
- package/dist/js/node/commands/dev.js +126 -0
- package/dist/js/node/commands/index.js +19 -0
- package/dist/js/node/commands/inspect.js +61 -0
- package/dist/js/node/commands/serve.js +83 -0
- package/dist/js/node/config/default.js +197 -0
- package/dist/js/node/config/index.js +19 -0
- package/dist/js/node/config/initialize/index.js +35 -0
- package/dist/js/node/config/initialize/inits.js +177 -0
- package/dist/js/node/config/legacy/createHtmlConfig.js +58 -0
- package/dist/js/node/config/legacy/createOutputConfig.js +91 -0
- package/dist/js/node/config/legacy/createSourceConfig.js +62 -0
- package/dist/js/node/config/legacy/createToolsConfig.js +65 -0
- package/dist/js/node/config/legacy/index.js +75 -0
- package/dist/js/node/defineConfig.js +49 -0
- package/dist/js/node/exports/server.js +27 -0
- package/dist/js/node/hooks.js +54 -0
- package/dist/js/node/index.js +245 -0
- package/dist/js/node/initialize/index.js +141 -0
- package/dist/js/node/locale/en.js +59 -0
- package/dist/js/node/locale/index.js +33 -0
- package/dist/js/node/locale/zh.js +59 -0
- package/dist/js/node/schema/Schema.js +63 -0
- package/dist/js/node/schema/index.js +118 -0
- package/dist/js/node/schema/legacy.js +169 -0
- package/dist/js/node/types/config/deploy.js +15 -0
- package/dist/js/node/types/config/dev.js +15 -0
- package/dist/js/node/types/config/experiments.js +15 -0
- package/dist/js/node/types/config/html.js +15 -0
- package/dist/js/node/types/config/index.js +17 -0
- package/dist/js/node/types/config/output.js +15 -0
- package/dist/js/node/types/config/performance.js +15 -0
- package/dist/js/node/types/config/security.js +15 -0
- package/dist/js/node/types/config/source.js +15 -0
- package/dist/js/node/types/config/tools.js +15 -0
- package/dist/js/node/types/hooks.js +15 -0
- package/dist/js/node/types/index.js +19 -0
- package/dist/js/node/types/legacyConfig/deploy.js +15 -0
- package/dist/js/node/types/legacyConfig/dev.js +15 -0
- package/dist/js/node/types/legacyConfig/index.js +15 -0
- package/dist/js/node/types/legacyConfig/output.js +15 -0
- package/dist/js/node/types/legacyConfig/source.js +15 -0
- package/dist/js/node/types/legacyConfig/tools.js +15 -0
- package/dist/js/node/types/utils.js +15 -0
- package/dist/js/node/utils/config.js +153 -0
- package/dist/js/node/utils/createServer.js +106 -0
- package/dist/js/node/utils/env.js +38 -0
- package/dist/js/node/utils/generateWatchFiles.js +85 -0
- package/dist/js/node/utils/getSelectedEntries.js +81 -0
- package/dist/js/node/utils/getServerInternalPlugins.js +79 -0
- package/dist/js/node/utils/language.js +31 -0
- package/dist/js/node/utils/printInstructions.js +54 -0
- package/dist/js/node/utils/restart.js +67 -0
- package/dist/js/node/utils/routes.js +59 -0
- package/dist/js/node/utils/types.js +15 -0
- package/dist/js/treeshaking/analyze/constants.js +42 -0
- package/dist/js/treeshaking/analyze/generateCode.js +485 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +62 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +233 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +231 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +3 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +23 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +107 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +302 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +224 -0
- package/dist/js/treeshaking/analyze/index.js +702 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +47 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +13 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +409 -0
- package/dist/js/treeshaking/analyze/templates.js +465 -0
- package/dist/js/treeshaking/analyze/utils.js +374 -0
- package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/RouterPlugin.js +346 -0
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +16 -0
- package/dist/js/treeshaking/builder/generator/index.js +199 -0
- package/dist/js/treeshaking/builder/index.js +175 -0
- package/dist/js/treeshaking/builder/shared/builderPlugins/adapterModern.js +300 -0
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +110 -0
- package/dist/js/treeshaking/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +72 -0
- package/dist/js/treeshaking/builder/shared/createCopyPattern.js +40 -0
- package/dist/js/treeshaking/builder/shared/index.js +3 -0
- package/dist/js/treeshaking/builder/shared/loaders/serverModuleLoader.js +5 -0
- package/dist/js/treeshaking/builder/shared/types.js +1 -0
- package/dist/js/treeshaking/commands/build.js +291 -0
- package/dist/js/treeshaking/commands/deploy.js +154 -0
- package/dist/js/treeshaking/commands/dev.js +301 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +149 -0
- package/dist/js/treeshaking/commands/serve.js +199 -0
- package/dist/js/treeshaking/config/default.js +210 -0
- package/dist/js/treeshaking/config/index.js +3 -0
- package/dist/js/treeshaking/config/initialize/index.js +10 -0
- package/dist/js/treeshaking/config/initialize/inits.js +211 -0
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/legacy/createOutputConfig.js +41 -0
- package/dist/js/treeshaking/config/legacy/createSourceConfig.js +42 -0
- package/dist/js/treeshaking/config/legacy/createToolsConfig.js +23 -0
- package/dist/js/treeshaking/config/legacy/index.js +38 -0
- package/dist/js/treeshaking/defineConfig.js +61 -0
- package/dist/js/treeshaking/exports/server.js +2 -0
- package/dist/js/treeshaking/hooks.js +29 -0
- package/dist/js/treeshaking/index.js +713 -0
- package/dist/js/treeshaking/initialize/index.js +284 -0
- package/dist/js/treeshaking/locale/en.js +38 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +38 -0
- package/dist/js/treeshaking/schema/Schema.js +273 -0
- package/dist/js/treeshaking/schema/index.js +181 -0
- package/dist/js/treeshaking/schema/legacy.js +337 -0
- package/dist/js/treeshaking/types/config/deploy.js +1 -0
- package/dist/js/treeshaking/types/config/dev.js +1 -0
- package/dist/js/treeshaking/types/config/experiments.js +1 -0
- package/dist/js/treeshaking/types/config/html.js +1 -0
- package/dist/js/treeshaking/types/config/index.js +1 -0
- package/dist/js/treeshaking/types/config/output.js +1 -0
- package/dist/js/treeshaking/types/config/performance.js +1 -0
- package/dist/js/treeshaking/types/config/security.js +1 -0
- package/dist/js/treeshaking/types/config/source.js +1 -0
- package/dist/js/treeshaking/types/config/tools.js +1 -0
- package/dist/js/treeshaking/types/hooks.js +1 -0
- package/dist/js/treeshaking/types/index.js +3 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +1 -0
- package/dist/js/treeshaking/types/utils.js +1 -0
- package/dist/js/treeshaking/utils/config.js +302 -0
- package/dist/js/treeshaking/utils/createServer.js +258 -0
- package/dist/js/treeshaking/utils/env.js +13 -0
- package/dist/js/treeshaking/utils/generateWatchFiles.js +214 -0
- package/dist/js/treeshaking/utils/getSelectedEntries.js +186 -0
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +210 -0
- package/dist/js/treeshaking/utils/language.js +6 -0
- package/dist/js/treeshaking/utils/printInstructions.js +152 -0
- package/dist/js/treeshaking/utils/restart.js +187 -0
- package/dist/js/treeshaking/utils/routes.js +153 -0
- package/dist/js/treeshaking/utils/types.js +1 -0
- package/package.json +13 -13
|
@@ -0,0 +1,300 @@
|
|
|
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 };
|
|
@@ -0,0 +1,110 @@
|
|
|
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 };
|
|
@@ -0,0 +1,72 @@
|
|
|
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 };
|
|
@@ -0,0 +1,40 @@
|
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|