@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.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/.eslintignore +7 -7
- package/.eslintrc.js +180 -179
- package/.prettierrc +6 -6
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +27 -951
- package/bin/cli.js +483 -483
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +678 -0
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/jest.config.js +8 -12
- package/lib/configs/libAlias.js +10 -3
- package/lib/configs/resolvers.js +38 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +17 -22
- package/lib/configs/webpack.docs.config.js +10 -15
- package/lib/configs/webpack.impact.config.js +11 -11
- package/lib/configs/webpack.prod.config.js +22 -24
- package/lib/constants.js +31 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +42 -22
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -0
- package/lib/pluginUtils/getDevPlugins.js +19 -39
- package/lib/pluginUtils/getProdPlugins.js +29 -47
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -24
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +54 -30
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +37 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +248 -0
- package/lib/postcss-plugins/variableModifier.js +1 -0
- package/lib/schemas/index.js +36 -8
- package/lib/servers/docsServerCore.js +13 -12
- package/lib/servers/getCliPath.js +1 -1
- package/lib/servers/httpsOptions.js +40 -9
- package/lib/servers/nowatchserver.js +12 -11
- package/lib/servers/server.js +14 -13
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/getOptions.js +42 -14
- package/lib/utils/resultSchema.json +73 -73
- package/npm8.md +9 -9
- package/package.json +119 -148
- package/postpublish.js +8 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1493
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
- package/cert/Tsicsezwild-22-23.crt +0 -37
- package/cert/Tsicsezwild-22-23.key +0 -27
package/lib/constants.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.cliRootPath = exports.cliNodemodulesPath = exports.appPath = exports.CONFIG_ROOT = exports.BASE_CONFIG_KEY = void 0;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
const BASE_CONFIG_KEY = 'react-cli';
|
|
13
|
+
exports.BASE_CONFIG_KEY = BASE_CONFIG_KEY;
|
|
14
|
+
|
|
15
|
+
const cliRootPath = _path.default.resolve(__dirname, '..');
|
|
16
|
+
|
|
17
|
+
exports.cliRootPath = cliRootPath;
|
|
18
|
+
const CONFIG_ROOT = 'react-cli';
|
|
19
|
+
exports.CONFIG_ROOT = CONFIG_ROOT;
|
|
20
|
+
|
|
21
|
+
const cliNodemodulesPath = _path.default.resolve(cliRootPath, 'node_modules'); // export const babelrcPath = join(cliRootPath, '.babelrc');
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.cliNodemodulesPath = cliNodemodulesPath;
|
|
25
|
+
const appPath = process.cwd(); // export const appInitialHTMLTemplatePath = path.join(
|
|
26
|
+
// process.cwd(),
|
|
27
|
+
// 'src',
|
|
28
|
+
// 'index.html'
|
|
29
|
+
// );
|
|
30
|
+
|
|
31
|
+
exports.appPath = appPath;
|
|
@@ -6,23 +6,32 @@ var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classna
|
|
|
6
6
|
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
8
|
|
|
9
|
+
var _utils = require("../../utils");
|
|
10
|
+
|
|
9
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
12
|
|
|
11
13
|
let count = 0;
|
|
14
|
+
const options = (0, _utils.getOptions)();
|
|
15
|
+
const {
|
|
16
|
+
classnameFormat
|
|
17
|
+
} = options.test;
|
|
12
18
|
module.exports = {
|
|
13
19
|
process: function (src) {
|
|
14
20
|
count++;
|
|
15
|
-
|
|
21
|
+
const opts = {
|
|
16
22
|
hashType: 'md5',
|
|
17
|
-
digestType: 'base32'
|
|
23
|
+
digestType: 'base32',
|
|
24
|
+
maxLength: 6,
|
|
25
|
+
type: '.json',
|
|
26
|
+
classnameFormat: classnameFormat,
|
|
27
|
+
outputName: `jsonFile_test_${count}`
|
|
18
28
|
};
|
|
19
|
-
|
|
20
|
-
opts.type = '.json';
|
|
21
|
-
opts.outputName = `jsonFile_test_${count}`;
|
|
22
|
-
let processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
|
|
29
|
+
const processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
|
|
23
30
|
processor.process(src).css;
|
|
24
31
|
|
|
25
|
-
|
|
32
|
+
const jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
|
|
33
|
+
|
|
34
|
+
_fs.default.unlinkSync(`jsonFile_test_${count}.json`);
|
|
26
35
|
|
|
27
36
|
return `module.exports =${jsonMap}`;
|
|
28
37
|
}
|
|
@@ -79,39 +79,39 @@ function createNameTemplate(enableChunkHash) {
|
|
|
79
79
|
const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
|
|
80
80
|
return `[name]${ext}`;
|
|
81
81
|
}
|
|
82
|
-
/*
|
|
83
|
-
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
|
84
|
-
const nameTemplate = createNameTemplate(enableChunkHash);
|
|
85
|
-
return [
|
|
86
|
-
configImageLoader(nameTemplate),
|
|
87
|
-
configFontLoader(nameTemplate),
|
|
88
|
-
configSVGLoader(nameTemplate),
|
|
89
|
-
configAudioLoader(nameTemplate)
|
|
90
|
-
];
|
|
91
|
-
}
|
|
82
|
+
/*
|
|
83
|
+
export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
|
|
84
|
+
const nameTemplate = createNameTemplate(enableChunkHash);
|
|
85
|
+
return [
|
|
86
|
+
configImageLoader(nameTemplate),
|
|
87
|
+
configFontLoader(nameTemplate),
|
|
88
|
+
configSVGLoader(nameTemplate),
|
|
89
|
+
configAudioLoader(nameTemplate)
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
92
|
*/
|
|
93
93
|
|
|
94
|
-
/*
|
|
95
|
-
export function createLoaderOptionObject(
|
|
96
|
-
loaderName,
|
|
97
|
-
nameTemplate,
|
|
98
|
-
fallback,
|
|
99
|
-
limit = 1000
|
|
100
|
-
) {
|
|
101
|
-
return {
|
|
102
|
-
loader: loaderName,
|
|
103
|
-
options: {
|
|
104
|
-
limit,
|
|
105
|
-
name: nameTemplate,
|
|
106
|
-
fallback
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function configLoaderObject(filter, loaderAndOptions) {
|
|
112
|
-
return {
|
|
113
|
-
test: filter,
|
|
114
|
-
use: loaderAndOptions
|
|
115
|
-
};
|
|
116
|
-
}
|
|
94
|
+
/*
|
|
95
|
+
export function createLoaderOptionObject(
|
|
96
|
+
loaderName,
|
|
97
|
+
nameTemplate,
|
|
98
|
+
fallback,
|
|
99
|
+
limit = 1000
|
|
100
|
+
) {
|
|
101
|
+
return {
|
|
102
|
+
loader: loaderName,
|
|
103
|
+
options: {
|
|
104
|
+
limit,
|
|
105
|
+
name: nameTemplate,
|
|
106
|
+
fallback
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function configLoaderObject(filter, loaderAndOptions) {
|
|
112
|
+
return {
|
|
113
|
+
test: filter,
|
|
114
|
+
use: loaderAndOptions
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
117
|
*/
|
|
@@ -13,14 +13,27 @@ var _utils = require("../utils");
|
|
|
13
13
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
let isWin = process.platform === 'win32';
|
|
16
|
+
const fs = require('fs');
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
const options = (0, _utils.getOptions)();
|
|
19
|
+
const isWin = process.platform === 'win32';
|
|
20
|
+
|
|
21
|
+
function windowsModification(array) {
|
|
22
|
+
return isWin ? array.map(r => r.replace(/\//g, '\\')) : array;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function excludeEmptyCheckPlugin({
|
|
26
|
+
enable,
|
|
27
|
+
ignore,
|
|
28
|
+
plugins
|
|
29
|
+
}) {
|
|
30
|
+
return enable ? ignore.length === 0 ? plugins : [require('../postcss-plugins/ExcludePlugin')({
|
|
31
|
+
ignore,
|
|
32
|
+
plugins
|
|
33
|
+
})] : [];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariableReplacementConfig, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
|
|
24
37
|
const {
|
|
25
38
|
devCssFileBountry
|
|
26
39
|
} = options.app;
|
|
@@ -30,15 +43,11 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
|
|
|
30
43
|
const {
|
|
31
44
|
cssSelectorZipPath
|
|
32
45
|
} = options.impactService;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
let rtlExcludeLocal = windowsModification(exclude.rtl);
|
|
39
|
-
let hoverActiveExcludeLocal = windowsModification(exclude.hoverActive);
|
|
40
|
-
let combinerMediaQueryExcludeLocal = windowsModification(exclude.combinerMediaQuery);
|
|
41
|
-
let cssLoaderOptions = {
|
|
46
|
+
const rtlExcludeLocal = windowsModification(exclude.rtl);
|
|
47
|
+
const hoverActiveExcludeLocal = windowsModification(exclude.hoverActive);
|
|
48
|
+
const combinerMediaQueryExcludeLocal = windowsModification(exclude.combinerMediaQuery);
|
|
49
|
+
const cssVariableReplacementExcludeLocal = windowsModification(exclude.cssVariableReplacement);
|
|
50
|
+
const cssLoaderOptions = {
|
|
42
51
|
// importLoaders: hasRTL||hoverActive ? 1 : 0,
|
|
43
52
|
importLoaders: 1,
|
|
44
53
|
modules: {},
|
|
@@ -51,7 +60,13 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
|
|
|
51
60
|
cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
|
|
52
61
|
}
|
|
53
62
|
|
|
54
|
-
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace),
|
|
63
|
+
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), // ...excludeEmptyCheckPlugin({
|
|
64
|
+
// enable: true,
|
|
65
|
+
// ignore: [],
|
|
66
|
+
// plugins: [require('../postcss-plugins/variablePropertiesCollector').default()]
|
|
67
|
+
// }),
|
|
68
|
+
...excludeEmptyCheckPlugin({
|
|
69
|
+
enable: plugins.hasRTL,
|
|
55
70
|
ignore: rtlExcludeLocal,
|
|
56
71
|
plugins: [require('@zohodesk/postcss-rtl')({
|
|
57
72
|
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
|
@@ -62,14 +77,19 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
|
|
|
62
77
|
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
|
63
78
|
}
|
|
64
79
|
})]
|
|
65
|
-
}),
|
|
80
|
+
}), ...excludeEmptyCheckPlugin({
|
|
81
|
+
enable: plugins.combinerMediaQuery,
|
|
66
82
|
ignore: combinerMediaQueryExcludeLocal,
|
|
67
83
|
plugins: [require('postcss-combine-media-query')]
|
|
68
|
-
}),
|
|
84
|
+
}), ...excludeEmptyCheckPlugin({
|
|
85
|
+
enable: plugins.hoverActive,
|
|
69
86
|
ignore: hoverActiveExcludeLocal,
|
|
70
|
-
plugins: [require('../postcss-plugins/hoverActivePlugin')]
|
|
71
|
-
})
|
|
72
|
-
|
|
87
|
+
plugins: [require('../postcss-plugins/hoverActivePlugin')(mediaQueryHoverActiveString)]
|
|
88
|
+
}), ...excludeEmptyCheckPlugin({
|
|
89
|
+
enable: plugins.cssVariableReplacement,
|
|
90
|
+
ignore: cssVariableReplacementExcludeLocal,
|
|
91
|
+
plugins: [fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index')(cssVariableReplacementConfig)]
|
|
92
|
+
})].filter(Boolean);
|
|
73
93
|
return [cssSelectorZipPath && {
|
|
74
94
|
loader: require.resolve('../loaders/selectorMappingLoader')
|
|
75
95
|
}, {
|
|
@@ -16,7 +16,7 @@ var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntry
|
|
|
16
16
|
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
|
|
19
|
-
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
|
19
|
+
/* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
|
|
20
20
|
import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
|
|
21
21
|
const schema = {
|
|
22
22
|
'type': 'object',
|
|
@@ -80,14 +80,14 @@ function pitch(request) {
|
|
|
80
80
|
globalObject: 'self'
|
|
81
81
|
};
|
|
82
82
|
workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
|
|
83
|
-
/*
|
|
84
|
-
new WebWorkerTemplatePlugin().apply(workerContext.compiler);
|
|
85
|
-
|
|
86
|
-
if (compilerOptions.externals) {
|
|
87
|
-
new ExternalsPlugin(
|
|
88
|
-
getExternalsType(compilerOptions),
|
|
89
|
-
compilerOptions.externals
|
|
90
|
-
).apply(workerContext.compiler);
|
|
83
|
+
/*
|
|
84
|
+
new WebWorkerTemplatePlugin().apply(workerContext.compiler);
|
|
85
|
+
|
|
86
|
+
if (compilerOptions.externals) {
|
|
87
|
+
new ExternalsPlugin(
|
|
88
|
+
getExternalsType(compilerOptions),
|
|
89
|
+
compilerOptions.externals
|
|
90
|
+
).apply(workerContext.compiler);
|
|
91
91
|
} */
|
|
92
92
|
|
|
93
93
|
new _SingleEntryPlugin.default(this.context, `!!${request}`, _path.default.parse(this.resourcePath).name).apply(workerContext.compiler);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.configHtmlWebpackPlugins = configHtmlWebpackPlugins;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
11
|
+
|
|
12
|
+
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
|
13
|
+
|
|
14
|
+
var _common = require("../common");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
const defaultHTMLMiniFyOption = {
|
|
19
|
+
collapseWhitespace: true,
|
|
20
|
+
minifyCSS: true,
|
|
21
|
+
minifyJS: true,
|
|
22
|
+
keepClosingSlash: true,
|
|
23
|
+
removeComments: false,
|
|
24
|
+
removeRedundantAttributes: true,
|
|
25
|
+
removeScriptTypeAttributes: true,
|
|
26
|
+
removeStyleLinkTypeAttributes: true,
|
|
27
|
+
useShortDoctype: true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
function configHtmlWebpackPlugins(plugins, {
|
|
31
|
+
enableChunkHash = false,
|
|
32
|
+
folder,
|
|
33
|
+
inject,
|
|
34
|
+
crossorigin,
|
|
35
|
+
hasEFC,
|
|
36
|
+
minify: minifyHtmlOptions = false
|
|
37
|
+
}) {
|
|
38
|
+
const optionsHtmlWebpack = {
|
|
39
|
+
chunksSortMode: 'none',
|
|
40
|
+
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
|
41
|
+
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
|
42
|
+
minify: minifyHtmlOptions === true ? defaultHTMLMiniFyOption : minifyHtmlOptions === null ? false : minifyHtmlOptions,
|
|
43
|
+
// : typeof minifyHtmlOptions === 'object'
|
|
44
|
+
// ? minifyHtmlOptions
|
|
45
|
+
// : minifyHtmlOptions,,
|
|
46
|
+
templateParameters: _common.templateParameters,
|
|
47
|
+
scriptLoading: 'defer',
|
|
48
|
+
inject: inject
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
if (hasEFC) {
|
|
52
|
+
optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
|
|
56
|
+
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
|
57
|
+
crossorigin: 'anonymous'
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
@@ -15,10 +15,6 @@ var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin
|
|
|
15
15
|
|
|
16
16
|
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
|
17
17
|
|
|
18
|
-
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
19
|
-
|
|
20
|
-
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
|
21
|
-
|
|
22
18
|
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
|
23
19
|
|
|
24
20
|
var _RequireVariablePublicPlugin = _interopRequireDefault(require("../plugins/RequireVariablePublicPlugin"));
|
|
@@ -29,14 +25,14 @@ var _webpack = _interopRequireDefault(require("webpack"));
|
|
|
29
25
|
|
|
30
26
|
var _plugins = require("../plugins");
|
|
31
27
|
|
|
32
|
-
var _common = require("../common");
|
|
33
|
-
|
|
34
28
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
|
35
29
|
|
|
30
|
+
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
|
31
|
+
|
|
36
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const getDevPlugins = (options, publicPath) => {
|
|
35
|
+
const {
|
|
40
36
|
app: {
|
|
41
37
|
tpFolder,
|
|
42
38
|
folder,
|
|
@@ -68,7 +64,7 @@ let getDevPlugins = (options, publicPath) => {
|
|
|
68
64
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
|
69
65
|
const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
|
|
70
66
|
const cssRTLFileNameTempalte = 'css/[name].rtl.css';
|
|
71
|
-
|
|
67
|
+
const plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
|
|
72
68
|
__CLIENT__: true,
|
|
73
69
|
__TEST__: false,
|
|
74
70
|
__SERVER__: false,
|
|
@@ -103,11 +99,11 @@ let getDevPlugins = (options, publicPath) => {
|
|
|
103
99
|
}
|
|
104
100
|
|
|
105
101
|
const i18nManifestFileName = 'i18n-manifest.json';
|
|
106
|
-
/**
|
|
107
|
-
* NOTE:
|
|
108
|
-
* this file name ext .i18n.js added
|
|
109
|
-
* Because, in service worker they maintain cache as file name based
|
|
110
|
-
* So, to make differce we added .i18n.js ext.
|
|
102
|
+
/**
|
|
103
|
+
* NOTE:
|
|
104
|
+
* this file name ext .i18n.js added
|
|
105
|
+
* Because, in service worker they maintain cache as file name based
|
|
106
|
+
* So, to make differce we added .i18n.js ext.
|
|
111
107
|
*/
|
|
112
108
|
|
|
113
109
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
|
|
@@ -126,7 +122,7 @@ let getDevPlugins = (options, publicPath) => {
|
|
|
126
122
|
propertiesFolder: i18n.propertiesFolder
|
|
127
123
|
}));
|
|
128
124
|
} else {
|
|
129
|
-
|
|
125
|
+
const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
|
|
130
126
|
|
|
131
127
|
if (_fs.default.existsSync(i18nPath)) {
|
|
132
128
|
plugins.push(new _copyWebpackPlugin.default([{
|
|
@@ -146,20 +142,16 @@ let getDevPlugins = (options, publicPath) => {
|
|
|
146
142
|
collections: true,
|
|
147
143
|
shorthands: true
|
|
148
144
|
}));
|
|
145
|
+
(0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(plugins, {
|
|
146
|
+
enableChunkHash: false,
|
|
147
|
+
folder,
|
|
148
|
+
minify: false,
|
|
149
|
+
inject,
|
|
150
|
+
crossorigin,
|
|
151
|
+
hasEFC
|
|
152
|
+
});
|
|
149
153
|
|
|
150
154
|
if (hasEFC) {
|
|
151
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
|
152
|
-
chunksSortMode: 'none',
|
|
153
|
-
filename: 'index.html',
|
|
154
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
|
155
|
-
excludeChunks: ['efc', 'widget'],
|
|
156
|
-
templateParameters: _common.templateParameters,
|
|
157
|
-
scriptLoading: 'defer',
|
|
158
|
-
inject: inject
|
|
159
|
-
}));
|
|
160
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
|
161
|
-
crossorigin: 'anonymous'
|
|
162
|
-
}));
|
|
163
155
|
plugins.push(new _plugins.EFCPlugin({
|
|
164
156
|
isDevelopment: true,
|
|
165
157
|
i18nManifestFileName,
|
|
@@ -171,18 +163,6 @@ let getDevPlugins = (options, publicPath) => {
|
|
|
171
163
|
localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
|
|
172
164
|
|
|
173
165
|
}));
|
|
174
|
-
} else {
|
|
175
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
|
176
|
-
chunksSortMode: 'none',
|
|
177
|
-
filename: 'index.html',
|
|
178
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
|
179
|
-
templateParameters: _common.templateParameters,
|
|
180
|
-
scriptLoading: 'defer',
|
|
181
|
-
inject: inject
|
|
182
|
-
}));
|
|
183
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
|
184
|
-
crossorigin: 'anonymous'
|
|
185
|
-
}));
|
|
186
166
|
}
|
|
187
167
|
|
|
188
168
|
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
|
|
@@ -21,24 +21,22 @@ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plu
|
|
|
21
21
|
|
|
22
22
|
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
|
23
23
|
|
|
24
|
-
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
25
|
-
|
|
26
|
-
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
|
27
|
-
|
|
28
24
|
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
|
29
25
|
|
|
30
26
|
var _plugins = require("../plugins");
|
|
31
27
|
|
|
32
|
-
var _common = require("../common");
|
|
33
|
-
|
|
34
28
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
|
35
29
|
|
|
30
|
+
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
|
31
|
+
|
|
36
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
37
33
|
|
|
38
34
|
// eslint-disable-next-line no-unused-vars
|
|
39
|
-
|
|
35
|
+
const getProdPlugins = (options, publicPath = '') => {
|
|
40
36
|
let {
|
|
41
|
-
enableChunkHash
|
|
37
|
+
enableChunkHash
|
|
38
|
+
} = options.app;
|
|
39
|
+
const {
|
|
42
40
|
manifestFileName,
|
|
43
41
|
bundleAnalyze,
|
|
44
42
|
optimize,
|
|
@@ -56,13 +54,15 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
56
54
|
hasShadowDOM,
|
|
57
55
|
resourceHints,
|
|
58
56
|
serviceWorker,
|
|
59
|
-
htmlTemplate
|
|
60
|
-
inject
|
|
61
|
-
},
|
|
57
|
+
htmlTemplate,
|
|
62
58
|
tpHashMapping,
|
|
63
59
|
cdnMapping,
|
|
64
60
|
crossorigin
|
|
65
61
|
} = options.app;
|
|
62
|
+
const {
|
|
63
|
+
inject,
|
|
64
|
+
minify: minifyHtmlOptions
|
|
65
|
+
} = htmlTemplate;
|
|
66
66
|
const {
|
|
67
67
|
i18n
|
|
68
68
|
} = options;
|
|
@@ -79,9 +79,9 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
79
79
|
const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
|
|
80
80
|
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
|
|
81
81
|
const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
|
|
82
|
-
|
|
82
|
+
const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
|
83
83
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
|
84
|
-
|
|
84
|
+
const plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
|
|
85
85
|
__TEST__: false,
|
|
86
86
|
__DEVELOPMENT__: false,
|
|
87
87
|
__LOCAL_PRODUCTION__: isDevelopment,
|
|
@@ -108,11 +108,11 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const i18nManifestFileName = 'i18n-manifest.json';
|
|
111
|
-
/**
|
|
112
|
-
* NOTE:
|
|
113
|
-
* this file name ext .i18n.js added
|
|
114
|
-
* Because, in service worker they maintain cache as file name based
|
|
115
|
-
* So, to make differce we added .i18n.js ext.
|
|
111
|
+
/**
|
|
112
|
+
* NOTE:
|
|
113
|
+
* this file name ext .i18n.js added
|
|
114
|
+
* Because, in service worker they maintain cache as file name based
|
|
115
|
+
* So, to make differce we added .i18n.js ext.
|
|
116
116
|
*/
|
|
117
117
|
|
|
118
118
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
|
|
@@ -132,7 +132,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
132
132
|
propertiesFolder: i18n.propertiesFolder
|
|
133
133
|
}));
|
|
134
134
|
} else {
|
|
135
|
-
|
|
135
|
+
const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
|
|
136
136
|
|
|
137
137
|
if (_fs.default.existsSync(i18nPath)) {
|
|
138
138
|
plugins.push(new _copyWebpackPlugin.default([{
|
|
@@ -148,21 +148,16 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
148
148
|
to: `./${tpFolder}/`,
|
|
149
149
|
toType: 'dir'
|
|
150
150
|
}]));
|
|
151
|
+
(0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(plugins, {
|
|
152
|
+
enableChunkHash,
|
|
153
|
+
folder,
|
|
154
|
+
inject,
|
|
155
|
+
minify: minifyHtmlOptions,
|
|
156
|
+
crossorigin,
|
|
157
|
+
hasEFC
|
|
158
|
+
});
|
|
151
159
|
|
|
152
160
|
if (hasEFC) {
|
|
153
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
|
154
|
-
chunksSortMode: 'none',
|
|
155
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
|
156
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
|
157
|
-
excludeChunks: ['efc', 'widget'],
|
|
158
|
-
minify: false,
|
|
159
|
-
templateParameters: _common.templateParameters,
|
|
160
|
-
scriptLoading: 'defer',
|
|
161
|
-
inject: inject
|
|
162
|
-
}));
|
|
163
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
|
164
|
-
crossorigin: 'anonymous'
|
|
165
|
-
}));
|
|
166
161
|
plugins.push(new _plugins.EFCPlugin({
|
|
167
162
|
isDevelopment,
|
|
168
163
|
serverUrl: publicPath,
|
|
@@ -175,19 +170,6 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
175
170
|
localeAttr: efcLocaleAttr,
|
|
176
171
|
cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
|
|
177
172
|
}));
|
|
178
|
-
} else {
|
|
179
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
|
180
|
-
chunksSortMode: 'none',
|
|
181
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
|
182
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
|
183
|
-
minify: false,
|
|
184
|
-
templateParameters: _common.templateParameters,
|
|
185
|
-
scriptLoading: 'defer',
|
|
186
|
-
inject: inject
|
|
187
|
-
}));
|
|
188
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
|
189
|
-
crossorigin: 'anonymous'
|
|
190
|
-
}));
|
|
191
173
|
}
|
|
192
174
|
|
|
193
175
|
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
|
|
@@ -201,7 +183,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
201
183
|
}));
|
|
202
184
|
|
|
203
185
|
if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
|
|
204
|
-
|
|
186
|
+
const {
|
|
205
187
|
callback
|
|
206
188
|
} = publicPaths;
|
|
207
189
|
plugins.push(callback ? new _plugins.PublicPathCallbackPlugin({
|
|
@@ -255,7 +237,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
|
255
237
|
}
|
|
256
238
|
|
|
257
239
|
if (!isDevelopment && serviceWorker.enableSw) {
|
|
258
|
-
|
|
240
|
+
const {
|
|
259
241
|
filePath,
|
|
260
242
|
fileName = 'sw.js',
|
|
261
243
|
exitPath = '/',
|
package/lib/plugins/EFCPlugin.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# EFC Plugin
|
|
2
|
-
|
|
3
|
-
In EFC plugin we are create sdk file for efc related purpose
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
# document will be soon
|
|
1
|
+
# EFC Plugin
|
|
2
|
+
|
|
3
|
+
In EFC plugin we are create sdk file for efc related purpose
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# document will be soon
|
|
@@ -116,10 +116,10 @@ class I18NInjectIntoIndexPlugin {
|
|
|
116
116
|
i18nObj = i18nFiles.reduce((res, next) => {
|
|
117
117
|
let fileName = next.replace(`i18n${_path.default.sep}`, '');
|
|
118
118
|
let splittedFileName = fileName.split('.');
|
|
119
|
-
/* if (this.isDevelopment) {
|
|
120
|
-
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
|
121
|
-
} else {
|
|
122
|
-
res[splittedFileName[0]] = fileName;
|
|
119
|
+
/* if (this.isDevelopment) {
|
|
120
|
+
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
|
121
|
+
} else {
|
|
122
|
+
res[splittedFileName[0]] = fileName;
|
|
123
123
|
} */
|
|
124
124
|
|
|
125
125
|
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|