@zohodesk/client_build_tool 0.0.1 → 0.0.2
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 +25 -4
- package/ConfigurationDocumentation.md +239 -73
- package/README.md +27 -4
- package/README_backup.md +2 -0
- package/TODO.md +1 -1
- package/coverage/addFilesNamesToManifestJson.js.html +148 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/addFilesNamesToManifestJson.js.html +148 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createInitialEntries.js.html +136 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/createManifestJson.js.html +181 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/findInitialFileNames.js.html +133 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.html +146 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/index.js.html +199 -0
- package/coverage/bundler/webpack/custom_plugins/AddManifestJson/removeHashFromFileName.js.html +127 -0
- package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js.html +346 -0
- package/coverage/bundler/webpack/custom_plugins/VariableConversionCollector/index.html +116 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/constants.js.html +94 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js.html +259 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.html +236 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/index.js.html +442 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/insertBefore.js.html +154 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js.html +142 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js.html +127 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js.html +139 -0
- package/coverage/{updateArrayWithDefault.js.html → bundler/webpack/custom_postcss_plugins/HoverActivePlugin/specialCases.js.html} +55 -67
- package/coverage/bundler/webpack/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js.html +193 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/SelectorReplace.js.html +292 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/ValueReplacer.js.html +223 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.html +116 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/VariableModificationPlugin/index.js.html +1126 -0
- package/coverage/bundler/webpack/custom_postcss_plugins/index.html +131 -0
- package/coverage/bundler/webpack/loaderConfigs/getSpecificPostCssPlugin.js.html +247 -0
- package/coverage/bundler/webpack/loaderConfigs/index.html +116 -0
- package/coverage/coverage-final.json +3 -1
- package/coverage/coverage-summary.json +4 -2
- package/coverage/createInitialEntries.js.html +136 -0
- package/coverage/dummy.js.html +238 -0
- package/coverage/index.html +51 -21
- package/coverage/index.js.html +169 -0
- package/coverage/isObject.js.html +94 -0
- package/coverage/isValid.js.html +106 -0
- package/coverage/removeHashFromFileName.js.html +127 -0
- package/docs/BabelCustomizations.md +55 -0
- package/lib/commands/build/preProcessor.js +12 -0
- package/lib/commands/buildEs/preProcessor.js +17 -0
- package/lib/commands/buildLib/preProcessor.js +17 -0
- package/lib/commands/pre_process/commandExecutor.js +18 -0
- package/lib/commands/pre_process/config.js +12 -0
- package/lib/commands/start/preProcessor.js +3 -1
- package/lib/schemas/defaultConfigValues.js +65 -29
- package/lib/schemas/defaultConfigValuesOnly.js +20 -1
- package/lib/shared/babel/addDefaultPlugins.js +15 -0
- package/lib/shared/babel/babelWebConfig.js +2 -2
- package/lib/shared/babel/getBabelPlugin.js +37 -0
- package/lib/shared/bundler/webpack/common/nameTemplates.js +31 -8
- package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -1
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -1
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +80 -0
- package/lib/shared/bundler/webpack/getCSSLoaders.js +2 -0
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +1 -53
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +7 -0
- package/lib/shared/bundler/webpack/outputConfig.js +9 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +20 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +25 -10
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +2 -2
- package/lib/shared/bundler/webpack/pluginConfigs/dummy.js +23 -0
- package/lib/shared/bundler/webpack/plugins.js +3 -1
- package/lib/shared/bundler/webpack/statsConfig.js +11 -2
- package/lib/shared/commands-utils/spawnSyncIO.js +5 -5
- package/lib/shared/pre_process/runPreProcess.js +58 -0
- package/lib/shared/server/mockApiHandler.js +1 -1
- package/npm-shrinkwrap.json +552 -2209
- package/package.json +8 -3
- package/result.json +1 -1
- package/unittest/index.html +33 -35
- package/lib/shared/babel/defaultBabelPlugins.js +0 -26
|
@@ -14,7 +14,8 @@ var _default = {
|
|
|
14
14
|
cli: 'context'
|
|
15
15
|
},
|
|
16
16
|
devtool: 'hidden-cheap-source-map',
|
|
17
|
-
|
|
17
|
+
statsLogConfig: null,
|
|
18
|
+
enableFileNameHashing: {
|
|
18
19
|
value: false,
|
|
19
20
|
cli: 'enable_hash'
|
|
20
21
|
},
|
|
@@ -22,18 +23,6 @@ var _default = {
|
|
|
22
23
|
value: false,
|
|
23
24
|
cli: 'bundle_analyze'
|
|
24
25
|
},
|
|
25
|
-
devConsoleExclude: {
|
|
26
|
-
value: false,
|
|
27
|
-
cli: 'bundle_analyze'
|
|
28
|
-
},
|
|
29
|
-
separateCssModules: {
|
|
30
|
-
value: false,
|
|
31
|
-
cli: 'separate_css_modules'
|
|
32
|
-
},
|
|
33
|
-
enableFileNameHashing: {
|
|
34
|
-
value: false,
|
|
35
|
-
cli: 'separate_css_modules'
|
|
36
|
-
},
|
|
37
26
|
enableMockReplace: {
|
|
38
27
|
value: false,
|
|
39
28
|
cli: 'enable_mock_replace'
|
|
@@ -68,7 +57,7 @@ var _default = {
|
|
|
68
57
|
cli: 'port'
|
|
69
58
|
},
|
|
70
59
|
domain: {
|
|
71
|
-
value:
|
|
60
|
+
value: null,
|
|
72
61
|
cli: 'domain'
|
|
73
62
|
},
|
|
74
63
|
disableContextURL: {
|
|
@@ -225,13 +214,35 @@ var _default = {
|
|
|
225
214
|
},
|
|
226
215
|
createSeparateSMap: {
|
|
227
216
|
value: false,
|
|
228
|
-
cli: '
|
|
217
|
+
cli: 'enable_smap'
|
|
229
218
|
},
|
|
230
219
|
babelCustomizations: {
|
|
231
220
|
browserList: null,
|
|
232
221
|
// NOTE: need to consider
|
|
233
222
|
// presets: [],
|
|
234
|
-
plugins: []
|
|
223
|
+
plugins: [],
|
|
224
|
+
removeAttribute: {
|
|
225
|
+
enable: false,
|
|
226
|
+
options: {
|
|
227
|
+
attributeNames: ['data-testid']
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
removePropTypes: {
|
|
231
|
+
enable: false,
|
|
232
|
+
options: {
|
|
233
|
+
mode: 'remove',
|
|
234
|
+
removeImport: true
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
devConsoleExclude: {
|
|
238
|
+
enable: {
|
|
239
|
+
value: false,
|
|
240
|
+
cli: 'console_exclude'
|
|
241
|
+
},
|
|
242
|
+
options: {
|
|
243
|
+
exclude: ['error']
|
|
244
|
+
}
|
|
245
|
+
}
|
|
235
246
|
},
|
|
236
247
|
webpackPlugins: [],
|
|
237
248
|
vendorPatterns: [],
|
|
@@ -241,14 +252,17 @@ var _default = {
|
|
|
241
252
|
patterns: ['*.css']
|
|
242
253
|
}],
|
|
243
254
|
cdnMapping: {
|
|
244
|
-
isCdnEnabled:
|
|
255
|
+
isCdnEnabled: {
|
|
256
|
+
value: false,
|
|
257
|
+
cli: 'enable_cdn'
|
|
258
|
+
},
|
|
245
259
|
variableName: '',
|
|
246
260
|
cssTemplate: '',
|
|
247
261
|
jsTemplate: '',
|
|
248
262
|
i18nTemplate: ''
|
|
249
263
|
},
|
|
250
264
|
manifestJson: {
|
|
251
|
-
enable:
|
|
265
|
+
enable: false
|
|
252
266
|
},
|
|
253
267
|
changeRuntimeChunkChar: '~',
|
|
254
268
|
serviceWorker: {
|
|
@@ -257,20 +271,42 @@ var _default = {
|
|
|
257
271
|
outputFilePath: '/v1.js',
|
|
258
272
|
replaceText: '//<!--AssetsFromBuild -->'
|
|
259
273
|
},
|
|
260
|
-
removeAttribute: {
|
|
261
|
-
enable: true,
|
|
262
|
-
attributeNames: ['data-testid']
|
|
263
|
-
},
|
|
264
274
|
customLoaders: [],
|
|
265
275
|
resourceHints: {
|
|
266
276
|
allowPrefetchingMultipleChunks: false
|
|
267
277
|
},
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
278
|
+
devModeContentHashAllowedTypes: null,
|
|
279
|
+
devLikeHash: {
|
|
280
|
+
value: false,
|
|
281
|
+
cli: 'dev_like_hash'
|
|
282
|
+
},
|
|
283
|
+
disableReactDevWarning: {
|
|
284
|
+
value: false,
|
|
285
|
+
cli: 'disable_react_dev_warning'
|
|
286
|
+
},
|
|
287
|
+
preProcess: {
|
|
288
|
+
enable: {
|
|
289
|
+
value: false,
|
|
290
|
+
cli: 'enable_pre_process'
|
|
291
|
+
},
|
|
292
|
+
// This option is for tell the CBT to which is preprocessor js file path
|
|
293
|
+
runner: {
|
|
294
|
+
value: '',
|
|
295
|
+
cli: 'preprocessor'
|
|
296
|
+
},
|
|
297
|
+
// usually preprocessor run in nodemon for, start and docs , preprocessor
|
|
298
|
+
stopNodemon: {
|
|
299
|
+
value: false,
|
|
300
|
+
cli: 'stop_nodemon'
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
fileHashMappingToVariable: null,
|
|
304
|
+
customAttributes: {
|
|
305
|
+
enable: false,
|
|
306
|
+
attributes: null,
|
|
307
|
+
jsAttributes: null,
|
|
308
|
+
cssAttributes: null,
|
|
309
|
+
i18nAttributes: null
|
|
310
|
+
}
|
|
275
311
|
};
|
|
276
312
|
exports.default = _default;
|
|
@@ -11,7 +11,7 @@ var _os = require("os");
|
|
|
11
11
|
var _default = {
|
|
12
12
|
context: 'app',
|
|
13
13
|
devtool: 'hidden-cheap-source-map',
|
|
14
|
-
|
|
14
|
+
enableFileNameHashing: false,
|
|
15
15
|
bundleAnalyze: false,
|
|
16
16
|
enableMockReplace: false,
|
|
17
17
|
noPublicPath: false,
|
|
@@ -124,6 +124,25 @@ var _default = {
|
|
|
124
124
|
createSeparateSMap: false,
|
|
125
125
|
babelCustomizations: {
|
|
126
126
|
browserList: null,
|
|
127
|
+
removeAttribute: {
|
|
128
|
+
enable: false,
|
|
129
|
+
options: {
|
|
130
|
+
attributeNames: ['data-testid']
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
removePropTypes: {
|
|
134
|
+
enable: false,
|
|
135
|
+
options: {
|
|
136
|
+
mode: 'remove',
|
|
137
|
+
removeImport: true
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
devConsoleExclude: {
|
|
141
|
+
enable: false,
|
|
142
|
+
options: {
|
|
143
|
+
exclude: ['error']
|
|
144
|
+
}
|
|
145
|
+
},
|
|
127
146
|
// NOTE: need to consider
|
|
128
147
|
// presets: [],
|
|
129
148
|
plugins: []
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addDefaultPlugins = addDefaultPlugins;
|
|
7
|
+
|
|
8
|
+
function addDefaultPlugins(plugin, pluginName) {
|
|
9
|
+
if (plugin.enable) {
|
|
10
|
+
return [require.resolve(pluginName), plugin.options];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
@@ -9,7 +9,7 @@ var _helperCompilationTargets = _interopRequireDefault(require("@babel/helper-co
|
|
|
9
9
|
|
|
10
10
|
var _logger = require("../../logger");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _getBabelPlugin = require("./getBabelPlugin");
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
@@ -27,7 +27,7 @@ function babelWebConfig(options, mode) {
|
|
|
27
27
|
} = options.babelCustomizations;
|
|
28
28
|
return {
|
|
29
29
|
presets: [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react')],
|
|
30
|
-
plugins: customBabelPlugins(babelPlugins).concat((0,
|
|
30
|
+
plugins: customBabelPlugins(babelPlugins).concat((0, _getBabelPlugin.getBabelPlugin)(options)).filter(Boolean)
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getBabelPlugin = getBabelPlugin;
|
|
7
|
+
|
|
8
|
+
var _modeUtils = require("../bundler/webpack/common/modeUtils");
|
|
9
|
+
|
|
10
|
+
var _addDefaultPlugins = require("./addDefaultPlugins");
|
|
11
|
+
|
|
12
|
+
const babelPluginMapping = {
|
|
13
|
+
removeAttribute: './babel_plugins/removeAttributesPlugin',
|
|
14
|
+
removePropTypes: 'babel-plugin-transform-react-remove-prop-types',
|
|
15
|
+
devConsoleExclude: 'babel-plugin-transform-remove-console'
|
|
16
|
+
};
|
|
17
|
+
const babelPluginOrder = ['removeAttribute', 'removePropTypes', 'devConsoleExclude'];
|
|
18
|
+
|
|
19
|
+
function getBabelPlugin(options) {
|
|
20
|
+
const {
|
|
21
|
+
mode
|
|
22
|
+
} = options;
|
|
23
|
+
let customPlugins = [];
|
|
24
|
+
const {
|
|
25
|
+
babelCustomizations
|
|
26
|
+
} = options;
|
|
27
|
+
|
|
28
|
+
if ((0, _modeUtils.isProductionMode)(mode)) {
|
|
29
|
+
const configCreator = _addDefaultPlugins.addDefaultPlugins;
|
|
30
|
+
const plugins = babelPluginOrder.map(p => configCreator(babelCustomizations[p], babelPluginMapping[p]));
|
|
31
|
+
customPlugins = plugins;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return customPlugins.filter(Boolean);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
;
|
|
@@ -42,7 +42,7 @@ function createNameTemplate(name, useHash) {
|
|
|
42
42
|
return useHash ? name[1] : name[0];
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const defaultDevModeContentHashAllowedTypes = {
|
|
46
46
|
image: true,
|
|
47
47
|
font: true,
|
|
48
48
|
svg: true,
|
|
@@ -52,22 +52,45 @@ const devModeContentHashAllowedTypes = {
|
|
|
52
52
|
|
|
53
53
|
function nameTemplates(type, options) {
|
|
54
54
|
const {
|
|
55
|
-
|
|
56
|
-
mode
|
|
55
|
+
enableFileNameHashing,
|
|
56
|
+
mode,
|
|
57
|
+
devLikeHash
|
|
57
58
|
} = options;
|
|
59
|
+
let {
|
|
60
|
+
devModeContentHashAllowedTypes
|
|
61
|
+
} = options;
|
|
62
|
+
devModeContentHashAllowedTypes = devModeContentHashAllowedTypes || defaultDevModeContentHashAllowedTypes;
|
|
58
63
|
const templateName = templates[type];
|
|
59
64
|
|
|
60
65
|
if (!templateName) {
|
|
61
66
|
throw Error(`specified type not valid Type: ${type}`);
|
|
62
|
-
}
|
|
67
|
+
} // eslint-disable-next-line no-use-before-define
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
const useHash = checkCanWeAllowHash({
|
|
71
|
+
enableFileNameHashing,
|
|
72
|
+
devLikeHash: devLikeHash || (0, _modeUtils.isDevelopmentMode)(mode),
|
|
73
|
+
type,
|
|
74
|
+
devModeContentHashAllowedTypes
|
|
75
|
+
});
|
|
76
|
+
return createNameTemplate(templateName, useHash);
|
|
77
|
+
}
|
|
63
78
|
|
|
64
|
-
|
|
79
|
+
function checkCanWeAllowHash({
|
|
80
|
+
enableFileNameHashing,
|
|
81
|
+
devLikeHash,
|
|
82
|
+
type,
|
|
83
|
+
devModeContentHashAllowedTypes
|
|
84
|
+
}) {
|
|
85
|
+
if (!enableFileNameHashing) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
65
88
|
|
|
66
|
-
if (
|
|
67
|
-
|
|
89
|
+
if (devLikeHash) {
|
|
90
|
+
return devModeContentHashAllowedTypes[type];
|
|
68
91
|
}
|
|
69
92
|
|
|
70
|
-
return
|
|
93
|
+
return true;
|
|
71
94
|
} // export function cssDirNameTemplate(dir, options) {
|
|
72
95
|
// return nameTemplates('cssdir', options).replace(/\[dir\]/g, dir);
|
|
73
96
|
// }
|
|
@@ -29,7 +29,7 @@ class TPHashMappingPlugin {
|
|
|
29
29
|
|
|
30
30
|
getFiles() {
|
|
31
31
|
const hashMapping = {};
|
|
32
|
-
this.fileMappings.forEach(fileInfo => {
|
|
32
|
+
this.fileMappings.filter(f => f.enable).forEach(fileInfo => {
|
|
33
33
|
const filePath = _path.default.join(this.tpFolder, fileInfo.filePath);
|
|
34
34
|
|
|
35
35
|
if (_fs.default.existsSync(filePath)) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CustomAttributesPlugin = void 0;
|
|
7
|
+
|
|
8
|
+
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
|
9
|
+
|
|
10
|
+
var _webpack = require("webpack");
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
const pluginName = 'CustomAttributesPlugin';
|
|
15
|
+
|
|
16
|
+
function attributeSetTemplate(attributes, variableName) {
|
|
17
|
+
const str = [];
|
|
18
|
+
Object.keys(attributes).forEach(key => {
|
|
19
|
+
const val = attributes[key];
|
|
20
|
+
str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
|
|
21
|
+
});
|
|
22
|
+
return str;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function writeCss(attributes, code) {
|
|
26
|
+
const str = attributeSetTemplate(attributes, 'linkTag');
|
|
27
|
+
return code.replace('document.head.appendChild(linkTag);', `${str.join('')}document.head.appendChild(linkTag);`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function writeI18nJs(attributes, code) {
|
|
31
|
+
const str = attributeSetTemplate(attributes, 'scripTag');
|
|
32
|
+
return code.replace('document.head.appendChild(scriptTag);', `{${str.join('')} document.head.appendChild(scriptTag)};`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function writeJs(attributes, code) {
|
|
36
|
+
const str = attributeSetTemplate(attributes, 'script');
|
|
37
|
+
return code.replace('needAttach && document.head.appendChild(script);', `if(needAttach) {${str.join('')} document.head.appendChild(script)};`);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class CustomAttributesPlugin {
|
|
41
|
+
constructor(options) {
|
|
42
|
+
this.options = {
|
|
43
|
+
attributes: options.attributes,
|
|
44
|
+
jsAttributes: options.jsAttributes || options.attributes || {},
|
|
45
|
+
cssAttributes: options.cssAttributes || options.attributes || {},
|
|
46
|
+
i18nAttributes: options.i18nAttributes || options.attributes || {}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
apply(compiler) {
|
|
51
|
+
const {
|
|
52
|
+
RawSource
|
|
53
|
+
} = compiler.webpack.sources; // NOTE: we not using this, Reason currently this option is only need for EFC,
|
|
54
|
+
// So it do not needed.
|
|
55
|
+
|
|
56
|
+
const {
|
|
57
|
+
attributes
|
|
58
|
+
} = this.options;
|
|
59
|
+
attributes && new _htmlWebpackInjectAttributesPlugin.default(attributes).apply(compiler);
|
|
60
|
+
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
61
|
+
compilation.hooks.processAssets.tap({
|
|
62
|
+
name: pluginName,
|
|
63
|
+
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED
|
|
64
|
+
}, assets => {
|
|
65
|
+
const asset = Object.keys(assets).filter(k => /runtime.*\.js$/g.test(k));
|
|
66
|
+
asset.forEach(e => {
|
|
67
|
+
const runtimeJS = assets[e];
|
|
68
|
+
let code = runtimeJS.source();
|
|
69
|
+
code = writeCss(this.options.cssAttributes, code);
|
|
70
|
+
code = writeI18nJs(this.options.i18nAttributes, code);
|
|
71
|
+
code = writeJs(this.options.jsAttributes, code);
|
|
72
|
+
compilation.updateAsset(e, new RawSource(code));
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
exports.CustomAttributesPlugin = CustomAttributesPlugin;
|
|
@@ -16,6 +16,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
function getCSSLoaders(options) {
|
|
17
17
|
const cssLoaderOptions = (0, _getCssLoaderOptions.getCssLoaderOptions)(options);
|
|
18
18
|
return [{
|
|
19
|
+
loader: require.resolve('./loaders/miniCssFallBackLoader')
|
|
20
|
+
}, {
|
|
19
21
|
loader: _miniCssExtractPlugin.default.loader,
|
|
20
22
|
options: {
|
|
21
23
|
publicPath: '../'
|
|
@@ -11,7 +11,6 @@ exports.configVideoLoader = configVideoLoader;
|
|
|
11
11
|
|
|
12
12
|
var _nameTemplates = require("../common/nameTemplates");
|
|
13
13
|
|
|
14
|
-
// function getLoaderOptionQueryString(params) {
|
|
15
14
|
const ImageExtRegex = /\.jpe?g$|\.gif$|\.png|\.webp$/;
|
|
16
15
|
const FontExtRegex = /\.woff2|\.woff$|\.ttf$|\.eot$/;
|
|
17
16
|
const SVGExtRegex = /\.svg$/;
|
|
@@ -47,16 +46,6 @@ function createAssetLoader({
|
|
|
47
46
|
|
|
48
47
|
return conf;
|
|
49
48
|
}
|
|
50
|
-
/**
|
|
51
|
-
* @typedef {Object} LoaderConfig
|
|
52
|
-
* @property {Number} enableChunkHash
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @param {LoaderConfig} options
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
49
|
|
|
61
50
|
function configImageLoader(options) {
|
|
62
51
|
return createAssetLoader({
|
|
@@ -94,45 +83,4 @@ function configVideoLoader(options) {
|
|
|
94
83
|
test: VideoExtRegex,
|
|
95
84
|
nameTemplate: (0, _nameTemplates.nameTemplates)('video', options)
|
|
96
85
|
});
|
|
97
|
-
}
|
|
98
|
-
/*
|
|
99
|
-
export function createNameTemplate(enableChunkHash) {
|
|
100
|
-
const ext = `${enableChunkHash ? ".[hash:20]" : ""}.[ext]`;
|
|
101
|
-
return `[name]${ext}`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
|
105
|
-
const nameTemplate = createNameTemplate(enableChunkHash);
|
|
106
|
-
return [
|
|
107
|
-
configImageLoader(nameTemplate),
|
|
108
|
-
configFontLoader(nameTemplate),
|
|
109
|
-
configSVGLoader(nameTemplate),
|
|
110
|
-
configAudioLoader(nameTemplate)
|
|
111
|
-
];
|
|
112
|
-
}
|
|
113
|
-
*/
|
|
114
|
-
|
|
115
|
-
/*
|
|
116
|
-
export function createLoaderOptionObject(
|
|
117
|
-
loaderName,
|
|
118
|
-
nameTemplate,
|
|
119
|
-
fallback,
|
|
120
|
-
limit = 1000
|
|
121
|
-
) {
|
|
122
|
-
return {
|
|
123
|
-
loader: loaderName,
|
|
124
|
-
options: {
|
|
125
|
-
limit,
|
|
126
|
-
name: nameTemplate,
|
|
127
|
-
fallback
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function configLoaderObject(filter, loaderAndOptions) {
|
|
133
|
-
return {
|
|
134
|
-
test: filter,
|
|
135
|
-
use: loaderAndOptions
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
*/
|
|
86
|
+
}
|
|
@@ -16,13 +16,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
16
|
function outputConfig(options) {
|
|
17
17
|
const {
|
|
18
18
|
output,
|
|
19
|
-
publicPath
|
|
19
|
+
publicPath,
|
|
20
|
+
htmlTemplate
|
|
20
21
|
} = options;
|
|
21
|
-
|
|
22
|
+
const outputO = {
|
|
22
23
|
filename: (0, _nameTemplates.nameTemplates)('js', options),
|
|
23
24
|
chunkFilename: (0, _nameTemplates.nameTemplates)('chunkjs', options),
|
|
24
25
|
publicPath,
|
|
25
26
|
// clean: true,
|
|
26
27
|
path: _path.default.resolve(_constants.appPath, output)
|
|
27
28
|
};
|
|
29
|
+
|
|
30
|
+
if (htmlTemplate.crossorigin) {
|
|
31
|
+
outputO.crossOriginLoading = 'anonymous';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return outputO;
|
|
28
35
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.configCustomAttributesPlugin = configCustomAttributesPlugin;
|
|
7
|
+
|
|
8
|
+
var _custom_attribute_plugin = require("../custom_plugins/custom_attribute_plugin");
|
|
9
|
+
|
|
10
|
+
function configCustomAttributesPlugin(options) {
|
|
11
|
+
const {
|
|
12
|
+
customAttributes
|
|
13
|
+
} = options;
|
|
14
|
+
|
|
15
|
+
if (customAttributes.enable) {
|
|
16
|
+
return new _custom_attribute_plugin.CustomAttributesPlugin(customAttributes);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
@@ -9,9 +9,8 @@ var _webpack = require("webpack");
|
|
|
9
9
|
|
|
10
10
|
var _modeUtils = require("../common/modeUtils");
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
return new _webpack.DefinePlugin(mode === 'prod' ? {
|
|
12
|
+
function getDevEnvs(NODE_ENV) {
|
|
13
|
+
return {
|
|
15
14
|
__CLIENT__: true,
|
|
16
15
|
__TEST__: false,
|
|
17
16
|
__SERVER__: false,
|
|
@@ -19,18 +18,34 @@ function configEnvVariables(options) {
|
|
|
19
18
|
__LOCAL_PRODUCTION__: false,
|
|
20
19
|
__DEVTOOLS__: true,
|
|
21
20
|
__DOCS__: false,
|
|
22
|
-
NODE_ENV: JSON.stringify(mode),
|
|
23
21
|
'process.env': {
|
|
24
|
-
NODE_ENV
|
|
22
|
+
NODE_ENV
|
|
25
23
|
}
|
|
26
|
-
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getProdEnvs(isDevelopment) {
|
|
28
|
+
return {
|
|
29
|
+
__CLIENT__: true,
|
|
27
30
|
__TEST__: false,
|
|
31
|
+
__SERVER__: false,
|
|
28
32
|
__DEVELOPMENT__: false,
|
|
29
|
-
|
|
33
|
+
__LOCAL_PRODUCTION__: isDevelopment,
|
|
30
34
|
__DOCS__: false,
|
|
31
35
|
'process.env': {
|
|
32
36
|
NODE_ENV: JSON.stringify('production')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function configEnvVariables(options) {
|
|
42
|
+
// const mode = getWebpackMode(options);
|
|
43
|
+
const {
|
|
44
|
+
disableReactDevWarning,
|
|
45
|
+
mode,
|
|
46
|
+
devLikeHash
|
|
47
|
+
} = options;
|
|
48
|
+
const isDevelopment = devLikeHash;
|
|
49
|
+
const NODE_ENV = disableReactDevWarning ? JSON.stringify('production') : JSON.stringify('development');
|
|
50
|
+
return new _webpack.DefinePlugin((0, _modeUtils.isDevelopmentMode)(mode) ? getDevEnvs(NODE_ENV) : getProdEnvs(isDevelopment));
|
|
36
51
|
}
|
|
@@ -18,9 +18,9 @@ function configTPHashMappingPlugin(options) {
|
|
|
18
18
|
fileHashMappingToVariable,
|
|
19
19
|
context,
|
|
20
20
|
mode
|
|
21
|
-
} = options;
|
|
21
|
+
} = options;
|
|
22
22
|
|
|
23
|
-
if ((0, _modeUtils.isProductionMode)(mode)) {
|
|
23
|
+
if ((0, _modeUtils.isProductionMode)(mode) && fileHashMappingToVariable) {
|
|
24
24
|
return new _TPHashMappingPlugin.TPHashMappingPlugin({
|
|
25
25
|
fileMappings: fileHashMappingToVariable,
|
|
26
26
|
tpFolder: `${_path.default.join(process.cwd(), context)}`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.dummy = dummy;
|
|
7
|
+
|
|
8
|
+
class Demo {
|
|
9
|
+
// eslint-disable-next-line class-methods-use-this
|
|
10
|
+
apply(compiler) {
|
|
11
|
+
compiler.hooks.done.tap('vbxhb', stats => {
|
|
12
|
+
const statsJson = stats.toJson({
|
|
13
|
+
all: true
|
|
14
|
+
});
|
|
15
|
+
console.log(statsJson);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function dummy() {
|
|
22
|
+
return new Demo();
|
|
23
|
+
}
|
|
@@ -41,10 +41,12 @@ var _configSourceMapPlugin = require("./pluginConfigs/configSourceMapPlugin");
|
|
|
41
41
|
|
|
42
42
|
var _configTPHashMappingPlugin = require("./pluginConfigs/configTPHashMappingPlugin");
|
|
43
43
|
|
|
44
|
+
var _configCustomAttributesPlugin = require("./pluginConfigs/configCustomAttributesPlugin");
|
|
45
|
+
|
|
44
46
|
// import { IgnorePlugin } from 'webpack';
|
|
45
47
|
function plugins(options) {
|
|
46
48
|
const {
|
|
47
49
|
webpackPlugins
|
|
48
50
|
} = options;
|
|
49
|
-
return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), ...webpackPlugins].filter(Boolean);
|
|
51
|
+
return [(0, _configEnvVariables.configEnvVariables)(options), (0, _configCustomAttributesPlugin.configCustomAttributesPlugin)(options), (0, _configTPHashMappingPlugin.configTPHashMappingPlugin)(options), (0, _configCopyPublicFolders.configCopyPublicFolders)(options), (0, _configIgnorePlugin.configIgnorePlugin)(options), (0, _configMiniCSSExtractPlugin.configMiniCSSExtractPlugin)(options), (0, _configSelectorWeightPlugin.configSelectorWeightPlugin)(options), (0, _configVariableConversionPlugin.configVariableConversionPlugin)(options), (0, _configI18nSplitPlugin.configI18nSplitPlugin)(options), (0, _configRtlCssPlugin.configRtlCssPlugin)(options), (0, _configHtmlWebpackPlugin.configHtmlWebpackPlugin)(options), (0, _configCdnChangePlugin.configCdnChangePlugin)(options), (0, _configServiceWorkerPlugin.configServiceWorkerPlugin)(options), (0, _configEFCTemplatePlugin.configEFCTemplatePlugin)(options), (0, _configResourceHintsPlugin.configResourceHintsPlugin)(options), (0, _configBundleAnalyzer.configBundleAnalyzer)(options), (0, _configManifestJsonPlugin.configManifestJsonPlugin)(options), (0, _configSourceMapPlugin.configSourceMapPlugin)(options), (0, _configProgressPlugin.configProgressPlugin)(options), ...webpackPlugins].filter(Boolean);
|
|
50
52
|
}
|
|
@@ -7,13 +7,22 @@ exports.statsConfig = statsConfig;
|
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line no-unused-vars
|
|
9
9
|
function statsConfig(options) {
|
|
10
|
-
|
|
10
|
+
let {
|
|
11
|
+
statsLogConfig
|
|
12
|
+
} = options;
|
|
13
|
+
statsLogConfig = statsLogConfig || {};
|
|
14
|
+
|
|
15
|
+
if (typeof statsLogConfig === 'string') {
|
|
16
|
+
return statsLogConfig;
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
return {
|
|
12
20
|
preset: 'minimal',
|
|
13
21
|
warnings: false,
|
|
14
22
|
children: false,
|
|
15
23
|
colors: true,
|
|
16
|
-
errorDetails: true
|
|
24
|
+
errorDetails: true,
|
|
25
|
+
...statsLogConfig // excludeAssets: /i18n/,
|
|
17
26
|
// excludeAssets: /./,
|
|
18
27
|
// warningsFilter: /\[mini-css-extract-plugin\]/
|
|
19
28
|
|