@zohodesk/react-cli 0.0.1-test.148.2 → 1.0.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 -183
- package/.prettierrc +6 -0
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +1152 -678
- package/bin/cli.js +483 -392
- package/docs/CustomChunks.md +26 -0
- package/docs/DevServerPort.md +39 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/VariableConversion.md +724 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/common/index.js +6 -6
- package/lib/common/splitChunks.js +60 -12
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +18 -8
- package/lib/configs/libAlias.js +38 -0
- package/lib/configs/resolvers.js +40 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +59 -54
- package/lib/configs/webpack.docs.config.js +56 -53
- package/lib/configs/webpack.impact.config.js +54 -50
- package/lib/configs/webpack.prod.config.js +72 -47
- package/lib/constants.js +31 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +89 -21
- package/lib/loaderUtils/index.js +4 -4
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/scriptInstrumentLoader.js +2 -2
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -0
- package/lib/pluginUtils/getDevPlugins.js +69 -45
- package/lib/pluginUtils/getDocsPlugins.js +6 -8
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getProdPlugins.js +73 -58
- package/lib/pluginUtils/index.js +12 -12
- package/lib/plugins/CdnChangePlugin.js +16 -2
- package/lib/plugins/EFCPlugin.js +52 -20
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- 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 -86
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
- package/lib/plugins/ManifestPlugin.js +8 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +11 -7
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +13 -9
- package/lib/plugins/SourceMapHookPlugin.js +9 -3
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +352 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +36 -36
- package/lib/plugins/libraryImpactPlugin.js +14 -2
- package/lib/postcss-plugins/{ExcludeRTLPlugin.js → ExcludePlugin.js} +1 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +36 -32
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +389 -0
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +60 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +307 -0
- package/lib/postcss-plugins/variableModifier.js +244 -0
- package/lib/schemas/index.js +166 -11
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServerCore.js +16 -18
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/httpsOptions.js +49 -0
- package/lib/servers/nowatchserver.js +206 -0
- package/lib/servers/server.js +114 -82
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/linterConstant.js +1 -1
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/cssClassNameGenerate.js +9 -2
- package/lib/utils/cssURLReplacer.js +30 -43
- package/lib/utils/getCurrentBranch.js +1 -1
- package/lib/utils/getDependenciesImpactList.js +14 -12
- package/lib/utils/getFileType.js +49 -0
- package/lib/utils/getOptions.js +118 -10
- package/lib/utils/index.js +44 -20
- package/lib/utils/jsonHelper.js +12 -3
- package/lib/utils/reinstallDependencies.js +1 -1
- package/lib/utils/repoClone.js +16 -4
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +19 -2
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +121 -142
- package/postpublish.js +8 -0
- package/result.json +1 -0
- 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/unittest/index.html +37 -0
- package/cert/cert.pem +0 -105
- package/cert/key.pem +0 -30
|
@@ -10,21 +10,28 @@ var _pluginUtils = require("../pluginUtils");
|
|
|
10
10
|
|
|
11
11
|
var _loaderUtils = require("../loaderUtils");
|
|
12
12
|
|
|
13
|
+
var _configsAssetsLoaders = require("../loaderUtils/configsAssetsLoaders");
|
|
14
|
+
|
|
15
|
+
var _resolvers = require("./resolvers");
|
|
16
|
+
|
|
13
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
// import TerserPlugin from 'terser-webpack-plugin';
|
|
20
|
+
const options = (0, _utils.getOptions)();
|
|
21
|
+
const {
|
|
17
22
|
app: {
|
|
18
23
|
folder,
|
|
19
24
|
context,
|
|
20
|
-
enableChunkHash,
|
|
21
25
|
outputFolder,
|
|
22
26
|
disableES5Transpile,
|
|
23
27
|
removeAttribute,
|
|
24
28
|
enableSMap,
|
|
25
29
|
server,
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
plugins,
|
|
31
|
+
exclude,
|
|
32
|
+
mediaQueryHoverActiveString,
|
|
33
|
+
cssVariableReplacementConfig,
|
|
34
|
+
selectorWeightConfig,
|
|
28
35
|
cssUniqueness,
|
|
29
36
|
server: {
|
|
30
37
|
mode
|
|
@@ -35,30 +42,38 @@ let {
|
|
|
35
42
|
classNamePrefix,
|
|
36
43
|
selectorReplace,
|
|
37
44
|
removePropTypes,
|
|
38
|
-
devConsoleExculde
|
|
45
|
+
devConsoleExculde,
|
|
46
|
+
crossorigin
|
|
39
47
|
}
|
|
40
48
|
} = options;
|
|
41
|
-
let
|
|
42
|
-
|
|
49
|
+
let {
|
|
50
|
+
enableChunkHash
|
|
51
|
+
} = options.app;
|
|
52
|
+
const appPath = process.cwd();
|
|
53
|
+
const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
|
43
54
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
|
44
|
-
|
|
55
|
+
const output = {
|
|
45
56
|
path: _path.default.resolve(appPath, outputFolder),
|
|
46
|
-
filename: enableChunkHash ? '
|
|
47
|
-
chunkFilename: enableChunkHash ? '
|
|
57
|
+
filename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js' : 'js/[name]_.js',
|
|
58
|
+
chunkFilename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js' : 'js/[name]_.js',
|
|
48
59
|
jsonpFunction: `${context}Jsonp`,
|
|
49
|
-
sourceMapFilename: enableChunkHash ? '
|
|
60
|
+
sourceMapFilename: enableChunkHash ? 'js/[name].[chunkhash:20]_.js.map' : 'js/[name]_.js.map'
|
|
50
61
|
};
|
|
51
62
|
|
|
63
|
+
if (crossorigin) {
|
|
64
|
+
output.crossOriginLoading = 'anonymous';
|
|
65
|
+
}
|
|
66
|
+
|
|
52
67
|
if (isDevelopment) {
|
|
53
|
-
|
|
68
|
+
const {
|
|
54
69
|
disableContextURL
|
|
55
70
|
} = server;
|
|
56
|
-
|
|
57
|
-
|
|
71
|
+
const contextURL = disableContextURL ? '' : context;
|
|
72
|
+
const serverUrl = (0, _utils.getServerURL)(server, 'https');
|
|
58
73
|
output.publicPath = `${[serverUrl, contextURL].filter(a => a).join('/')}/`;
|
|
59
74
|
}
|
|
60
75
|
|
|
61
|
-
|
|
76
|
+
const shouldRemovePropTypes = !isDevelopment && removePropTypes;
|
|
62
77
|
module.exports = {
|
|
63
78
|
entry: (0, _common.getEntries)(options, 'production'),
|
|
64
79
|
devtool: isDevelopment ? 'cheap-module-source-map' : enableSMap ? 'hidden-source-map' : 'none',
|
|
@@ -71,12 +86,23 @@ module.exports = {
|
|
|
71
86
|
},
|
|
72
87
|
concatenateModules: true,
|
|
73
88
|
minimize: true,
|
|
89
|
+
// by default if minimize: true in webpack minimize then webpack automaticaly add TerserPlugin,
|
|
90
|
+
// So we are overrideing it.
|
|
91
|
+
// minimizer: [
|
|
92
|
+
// new TerserPlugin({
|
|
93
|
+
// cache: true,
|
|
94
|
+
// parallel: true,
|
|
95
|
+
// sourceMap: isDevelopment && enableSMap,
|
|
96
|
+
// exclude: /\/smap/
|
|
97
|
+
// })
|
|
98
|
+
// ],
|
|
74
99
|
moduleIds: 'named'
|
|
75
100
|
},
|
|
76
101
|
stats: {
|
|
77
102
|
children: false,
|
|
78
103
|
colors: true,
|
|
79
104
|
// excludeAssets: /i18n/,
|
|
105
|
+
// excludeAssets: /./,
|
|
80
106
|
warningsFilter: /\[mini-css-extract-plugin\]/
|
|
81
107
|
},
|
|
82
108
|
plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
|
|
@@ -108,11 +134,12 @@ module.exports = {
|
|
|
108
134
|
}] : null].filter(Boolean),
|
|
109
135
|
cacheDirectory: true
|
|
110
136
|
}
|
|
111
|
-
}],
|
|
137
|
+
}].filter(Boolean),
|
|
138
|
+
// include: path.join(appPath, folder)
|
|
112
139
|
include: module => {
|
|
113
|
-
|
|
140
|
+
const srcPath = _path.default.join(appPath, folder);
|
|
114
141
|
|
|
115
|
-
|
|
142
|
+
const depsPath = _path.default.join(appPath, 'node_modules', '@zohodesk');
|
|
116
143
|
|
|
117
144
|
if (module.includes(srcPath) || devConsoleExculde && module.includes(depsPath)) {
|
|
118
145
|
return true;
|
|
@@ -123,10 +150,30 @@ module.exports = {
|
|
|
123
150
|
}, seperateCssModules ? {
|
|
124
151
|
test: /\.css$/,
|
|
125
152
|
exclude: /\.module\.css$/,
|
|
126
|
-
use: (0, _loaderUtils.getCSSLoaders)(
|
|
153
|
+
use: (0, _loaderUtils.getCSSLoaders)({
|
|
154
|
+
plugins,
|
|
155
|
+
exclude,
|
|
156
|
+
cssVariableReplacementConfig,
|
|
157
|
+
selectorWeightConfig,
|
|
158
|
+
mediaQueryHoverActiveString,
|
|
159
|
+
classNameBlob: '[local]',
|
|
160
|
+
cssUniqueness: false,
|
|
161
|
+
selectorReplace: null
|
|
162
|
+
})
|
|
127
163
|
} : null, {
|
|
128
|
-
test: seperateCssModules ? /\.module\.css$/ :
|
|
129
|
-
use: (0, _loaderUtils.getCSSLoaders)(
|
|
164
|
+
test: seperateCssModules ? /\.module\.css$/ : /\.css$/,
|
|
165
|
+
use: (0, _loaderUtils.getCSSLoaders)({
|
|
166
|
+
plugins,
|
|
167
|
+
exclude,
|
|
168
|
+
mediaQueryHoverActiveString,
|
|
169
|
+
cssVariableReplacementConfig,
|
|
170
|
+
selectorWeightConfig,
|
|
171
|
+
classNameBlob: false,
|
|
172
|
+
cssUniqueness,
|
|
173
|
+
selectorReplace,
|
|
174
|
+
cssHashSelectors,
|
|
175
|
+
classNamePrefix
|
|
176
|
+
})
|
|
130
177
|
}, {
|
|
131
178
|
test: /\.jpe?g$|\.gif$|\.png$/,
|
|
132
179
|
use: [{
|
|
@@ -137,7 +184,7 @@ module.exports = {
|
|
|
137
184
|
fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
|
|
138
185
|
}
|
|
139
186
|
}]
|
|
140
|
-
}, {
|
|
187
|
+
}, (0, _configsAssetsLoaders.configVideoLoaderObj)(enableChunkHash ? './videos/[name].[hash:20].[ext]' : './videos/[name].[ext]'), {
|
|
141
188
|
test: /\.woff2|\.woff$|\.ttf$|\.eot$/,
|
|
142
189
|
use: [{
|
|
143
190
|
loader: 'url-loader',
|
|
@@ -187,28 +234,6 @@ module.exports = {
|
|
|
187
234
|
externals: {
|
|
188
235
|
ZC: '$ZC'
|
|
189
236
|
},
|
|
190
|
-
resolve:
|
|
191
|
-
|
|
192
|
-
alias: disableES5Transpile ? {
|
|
193
|
-
'@zohodesk/components/lib': '@zohodesk/components/es',
|
|
194
|
-
'@zohodesk/dot/lib': '@zohodesk/dot/es',
|
|
195
|
-
'@zohodesk/i18n/lib': '@zohodesk/i18n/es',
|
|
196
|
-
'@zohodesk/icons/lib': '@zohodesk/icons/es',
|
|
197
|
-
'@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
|
|
198
|
-
'@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
|
|
199
|
-
'@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
|
|
200
|
-
'@zohodesk/permissions/lib': '@zohodesk/permissions/es',
|
|
201
|
-
'@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
|
|
202
|
-
'@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
|
|
203
|
-
'@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
|
|
204
|
-
'@zohodesk/storage/lib': '@zohodesk/storage/es',
|
|
205
|
-
'@zohodesk/svg/lib': '@zohodesk/svg/es',
|
|
206
|
-
'@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
|
|
207
|
-
'@zohodesk/variables/lib': '@zohodesk/variables/es',
|
|
208
|
-
'@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
|
|
209
|
-
} : {}
|
|
210
|
-
},
|
|
211
|
-
resolveLoader: {
|
|
212
|
-
modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
|
|
213
|
-
}
|
|
237
|
+
resolve: (0, _resolvers.moduleResolver)(options),
|
|
238
|
+
resolveLoader: (0, _resolvers.loaderResolver)(options)
|
|
214
239
|
};
|
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
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.configAudioLoader = configAudioLoader;
|
|
7
|
+
exports.configFontLoader = configFontLoader;
|
|
8
|
+
exports.configImageLoader = configImageLoader;
|
|
9
|
+
exports.configSVGLoader = configSVGLoader;
|
|
10
|
+
exports.configVideoLoader = configVideoLoader;
|
|
11
|
+
exports.configVideoLoaderObj = configVideoLoaderObj;
|
|
12
|
+
exports.createNameTemplate = createNameTemplate;
|
|
13
|
+
|
|
14
|
+
var _path = _interopRequireDefault(require("path"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
// function getLoaderOptionQueryString(params) {
|
|
19
|
+
const ImageExtRegex = /\.jpe?g$|\.gif$|\.png|\.webp$/;
|
|
20
|
+
const FontExtRegex = /\.woff2|\.woff$|\.ttf$|\.eot$/;
|
|
21
|
+
const SVGExtRegex = /\.svg$/;
|
|
22
|
+
const AudioExtRegex = /\.ogg$/;
|
|
23
|
+
const VidioExtRegex = /\.mp4|\.webm$/;
|
|
24
|
+
|
|
25
|
+
function createLoaderOptionQueryString(loaderName, nameTemplate, limit = 1000) {
|
|
26
|
+
return `${loaderName}?limit=${limit}&name=${nameTemplate}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function configImageLoader(nameTemplate) {
|
|
30
|
+
return {
|
|
31
|
+
test: ImageExtRegex,
|
|
32
|
+
use: createLoaderOptionQueryString('url-loader', `./images/${nameTemplate}`)
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function configFontLoader(nameTemplate) {
|
|
37
|
+
return {
|
|
38
|
+
test: FontExtRegex,
|
|
39
|
+
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`)
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function configSVGLoader(nameTemplate) {
|
|
44
|
+
return {
|
|
45
|
+
test: SVGExtRegex,
|
|
46
|
+
use: createLoaderOptionQueryString('url-loader', `./fonts/${nameTemplate}`, 1)
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function configAudioLoader(nameTemplate) {
|
|
51
|
+
return {
|
|
52
|
+
test: AudioExtRegex,
|
|
53
|
+
use: createLoaderOptionQueryString('file-loader', `./fonts/${nameTemplate}`, 1)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function configVideoLoader(nameTemplate) {
|
|
58
|
+
return {
|
|
59
|
+
test: VidioExtRegex,
|
|
60
|
+
use: createLoaderOptionQueryString('url-loader', `./videos/${nameTemplate}`, 1)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function configVideoLoaderObj(nameTemplate) {
|
|
65
|
+
return {
|
|
66
|
+
test: VidioExtRegex,
|
|
67
|
+
use: {
|
|
68
|
+
loader: 'url-loader',
|
|
69
|
+
options: {
|
|
70
|
+
limit: 1000,
|
|
71
|
+
name: nameTemplate,
|
|
72
|
+
fallback: _path.default.join(__dirname, '..', 'loaders', 'fileLoader.js')
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function createNameTemplate(enableChunkHash) {
|
|
79
|
+
const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
|
|
80
|
+
return `[name]${ext}`;
|
|
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
|
+
}
|
|
92
|
+
*/
|
|
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
|
+
}
|
|
117
|
+
*/
|
|
@@ -9,24 +9,98 @@ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plu
|
|
|
9
9
|
|
|
10
10
|
var _cssClassNameGenerate = _interopRequireDefault(require("../utils/cssClassNameGenerate"));
|
|
11
11
|
|
|
12
|
+
var _utils = require("../utils");
|
|
13
|
+
|
|
14
|
+
var _windowsModification = require("./windowsModification");
|
|
15
|
+
|
|
12
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
|
|
20
|
+
const options = (0, _utils.getOptions)();
|
|
15
21
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
function excludeEmptyCheckPlugin({
|
|
23
|
+
enable,
|
|
24
|
+
ignore,
|
|
25
|
+
plugins
|
|
26
|
+
}) {
|
|
27
|
+
return enable ? ignore.length === 0 ? plugins : [require('../postcss-plugins/ExcludePlugin')({
|
|
28
|
+
ignore,
|
|
29
|
+
plugins
|
|
30
|
+
})] : [];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getCSSLoaders = optionsObj => {
|
|
34
|
+
const {
|
|
35
|
+
plugins,
|
|
36
|
+
exclude,
|
|
37
|
+
mediaQueryHoverActiveString,
|
|
38
|
+
cssVariableReplacementConfig,
|
|
39
|
+
classNameBlob,
|
|
40
|
+
cssUniqueness,
|
|
41
|
+
selectorReplace,
|
|
42
|
+
cssHashSelectors,
|
|
43
|
+
classNamePrefix
|
|
44
|
+
} = optionsObj; // console.log('plugins:')
|
|
45
|
+
// console.log(plugins)
|
|
46
|
+
// console.log('exclude:')
|
|
47
|
+
// console.log(exclude)
|
|
48
|
+
|
|
49
|
+
const {
|
|
50
|
+
devCssFileBountry
|
|
51
|
+
} = options.app;
|
|
52
|
+
const {
|
|
53
|
+
valueReplacer
|
|
54
|
+
} = options.css;
|
|
55
|
+
const {
|
|
56
|
+
cssSelectorZipPath
|
|
57
|
+
} = options.impactService;
|
|
58
|
+
const rtlExcludeLocal = (0, _windowsModification.windowsModification)(exclude.rtl);
|
|
59
|
+
const hoverActiveExcludeLocal = (0, _windowsModification.windowsModification)(exclude.hoverActive);
|
|
60
|
+
const combinerMediaQueryExcludeLocal = (0, _windowsModification.windowsModification)(exclude.combinerMediaQuery);
|
|
61
|
+
const cssVariableReplacementExcludeLocal = (0, _windowsModification.windowsModification)(exclude.cssVariableReplacement);
|
|
62
|
+
const cssLoaderOptions = {
|
|
63
|
+
// importLoaders: hasRTL||hoverActive ? 1 : 0,
|
|
64
|
+
importLoaders: 1,
|
|
65
|
+
modules: {},
|
|
66
|
+
sourceMap: true
|
|
21
67
|
};
|
|
22
68
|
|
|
23
69
|
if (classNameBlob) {
|
|
24
70
|
cssLoaderOptions.modules.localIdentName = classNameBlob;
|
|
25
71
|
} else {
|
|
26
72
|
cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
|
|
27
|
-
}
|
|
73
|
+
} // console.log('selector weight config : ', selectorWeightConfig);
|
|
74
|
+
|
|
28
75
|
|
|
29
|
-
|
|
76
|
+
const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), ...excludeEmptyCheckPlugin({
|
|
77
|
+
enable: plugins.hasRTL,
|
|
78
|
+
ignore: rtlExcludeLocal,
|
|
79
|
+
plugins: [require('@zohodesk/postcss-rtl')({
|
|
80
|
+
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
|
81
|
+
if (prefix === '[dir]') {
|
|
82
|
+
return selector;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
|
86
|
+
}
|
|
87
|
+
})]
|
|
88
|
+
}), ...excludeEmptyCheckPlugin({
|
|
89
|
+
enable: plugins.combinerMediaQuery,
|
|
90
|
+
ignore: combinerMediaQueryExcludeLocal,
|
|
91
|
+
plugins: [require('postcss-combine-media-query')]
|
|
92
|
+
}), ...excludeEmptyCheckPlugin({
|
|
93
|
+
enable: plugins.hoverActive,
|
|
94
|
+
ignore: hoverActiveExcludeLocal,
|
|
95
|
+
plugins: [require('../postcss-plugins/hoverActivePlugin')(mediaQueryHoverActiveString)]
|
|
96
|
+
}), ...excludeEmptyCheckPlugin({
|
|
97
|
+
enable: plugins.cssVariableReplacement,
|
|
98
|
+
ignore: cssVariableReplacementExcludeLocal,
|
|
99
|
+
plugins: [fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index').plugin(cssVariableReplacementConfig)]
|
|
100
|
+
})].filter(Boolean);
|
|
101
|
+
return [cssSelectorZipPath && {
|
|
102
|
+
loader: require.resolve('../loaders/selectorMappingLoader')
|
|
103
|
+
}, {
|
|
30
104
|
loader: _miniCssExtractPlugin.default.loader,
|
|
31
105
|
options: {
|
|
32
106
|
publicPath: '../'
|
|
@@ -34,23 +108,17 @@ let getCSSLoaders = (hasRTL, rtlExclude, classNameBlob, cssUniqueness, selectorR
|
|
|
34
108
|
}, {
|
|
35
109
|
loader: 'css-loader',
|
|
36
110
|
options: cssLoaderOptions
|
|
37
|
-
},
|
|
111
|
+
}, devCssFileBountry && {
|
|
112
|
+
loader: require.resolve('../loaders/fileBountryLoader'),
|
|
113
|
+
options: {
|
|
114
|
+
devCssFileBountry
|
|
115
|
+
}
|
|
116
|
+
}, postcssPlugins.length > 0 ? {
|
|
38
117
|
loader: 'postcss-loader',
|
|
39
118
|
options: {
|
|
40
119
|
ident: 'postcss',
|
|
41
120
|
plugins: function () {
|
|
42
|
-
return
|
|
43
|
-
ignore: rtlExcludeLocal,
|
|
44
|
-
plugins: [require('@zohodesk/postcss-rtl')({
|
|
45
|
-
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
|
46
|
-
if (prefix === '[dir]') {
|
|
47
|
-
return selector;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
|
51
|
-
}
|
|
52
|
-
})]
|
|
53
|
-
})].filter(Boolean);
|
|
121
|
+
return postcssPlugins;
|
|
54
122
|
}
|
|
55
123
|
}
|
|
56
124
|
} : null].filter(Boolean);
|
package/lib/loaderUtils/index.js
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "getCSSLoaders", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _getCSSLoaders.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "getDevJsLoaders", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _getDevJsLoaders.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.windowsModification = windowsModification;
|
|
7
|
+
const isWin = process.platform === 'win32';
|
|
8
|
+
|
|
9
|
+
function windowsModification(array) {
|
|
10
|
+
return isWin ? array && Array.isArray(array) && array.map(r => r.replace(/\//g, '\\')) : array;
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
|
4
|
+
|
|
5
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
+
|
|
7
|
+
module.exports = function (source) {
|
|
8
|
+
const {
|
|
9
|
+
rootContext,
|
|
10
|
+
resourcePath,
|
|
11
|
+
query
|
|
12
|
+
} = this;
|
|
13
|
+
const {
|
|
14
|
+
devCssFileBountry
|
|
15
|
+
} = query;
|
|
16
|
+
return `/*${devCssFileBountry} ${_path.default.relative(rootContext, resourcePath)}*/\n${source}`;
|
|
17
|
+
};
|
|
@@ -6,9 +6,9 @@ var _escodegen = _interopRequireDefault(require("escodegen"));
|
|
|
6
6
|
|
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
8
|
|
|
9
|
-
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
10
|
|
|
11
|
-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
12
|
|
|
13
13
|
let start = {
|
|
14
14
|
type: 'ExpressionStatement',
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _path = _interopRequireDefault(require("path"));
|
|
4
|
+
|
|
5
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
6
|
+
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
|
|
11
|
+
let options = (0, _utils.getOptions)();
|
|
12
|
+
const {
|
|
13
|
+
cssSelectorZipPath
|
|
14
|
+
} = options.impactService;
|
|
15
|
+
|
|
16
|
+
const zipname = _path.default.parse(cssSelectorZipPath).name; // console.log({ cssSelectorZipPath, zipname });
|
|
17
|
+
// TODO:NOTE: need to check about .. path related files creation
|
|
18
|
+
// for now no css files have given form react-cli need to make sure about it.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
let zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
|
|
22
|
+
|
|
23
|
+
if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
|
|
24
|
+
_fs.default.rmSync(zippath);
|
|
25
|
+
|
|
26
|
+
console.log('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
|
|
27
|
+
// console.log('created folder ==> ', dpath);
|
|
28
|
+
} // const minicssComment =
|
|
29
|
+
// '// extracted by mini-css-extract-plugin\n';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const startStr = '// extracted by mini-css-extract-plugin\n' + 'module.exports = ';
|
|
33
|
+
|
|
34
|
+
module.exports = function (source) {
|
|
35
|
+
const {
|
|
36
|
+
rootContext,
|
|
37
|
+
resourcePath
|
|
38
|
+
} = this;
|
|
39
|
+
|
|
40
|
+
const relativePath = _path.default.relative(rootContext, resourcePath);
|
|
41
|
+
|
|
42
|
+
let fpath = _path.default.join(rootContext, zipname, relativePath);
|
|
43
|
+
|
|
44
|
+
let originalpath = _path.default.join(rootContext, relativePath);
|
|
45
|
+
|
|
46
|
+
if (relativePath.startsWith('..')) {
|
|
47
|
+
throw `unexpected path ${relativePath}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
|
|
51
|
+
|
|
52
|
+
if (!_fs.default.existsSync(originalpath)) {
|
|
53
|
+
throw `originalpath not exixt ${originalpath}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!_fs.default.existsSync(dpath)) {
|
|
57
|
+
_fs.default.mkdirSync(dpath, {
|
|
58
|
+
recursive: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let jsonStr = '{}';
|
|
63
|
+
|
|
64
|
+
if (source.startsWith(startStr)) {
|
|
65
|
+
// source will be like
|
|
66
|
+
// `// extracted by mini-css-extract-plugin\nmodule.exports = {"app":"zd-app"};`
|
|
67
|
+
jsonStr = source.slice(startStr.length, -1);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_fs.default.writeFileSync(`${fpath}_map`, jsonStr);
|
|
71
|
+
|
|
72
|
+
_fs.default.writeFileSync(fpath, _fs.default.readFileSync(originalpath));
|
|
73
|
+
|
|
74
|
+
return source;
|
|
75
|
+
};
|