@zohodesk/react-cli 1.1.16 → 1.1.18-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +27 -0
- package/lib/babel/babel-option-utils/babel-preset-react-option.js +22 -0
- package/lib/babel/cmjs-plugins-presets.js +7 -1
- package/lib/babel/es-plugins-presets.js +7 -1
- package/lib/configs/webpack.dev.config.js +7 -2
- package/lib/configs/webpack.prod.config.js +9 -2
- package/lib/loaderUtils/getDevJsLoaders.js +5 -1
- package/lib/schemas/index.js +4 -0
- package/npm-shrinkwrap.json +42 -11
- package/package.json +4 -2
- package/packages/client_build_tool/lib/allCommandsConfigs.js +23 -0
- package/packages/client_build_tool/lib/buildToolLoggers.js +32 -0
- package/packages/client_build_tool/lib/commands/build/commandExecutor.js +21 -0
- package/packages/client_build_tool/lib/commands/build/config.js +12 -0
- package/packages/client_build_tool/lib/commands/build/errorHander.js +10 -0
- package/packages/client_build_tool/lib/commands/build/index.js +35 -0
- package/packages/client_build_tool/lib/commands/build/optionsProcesser.js +40 -0
- package/packages/client_build_tool/lib/commands/buildEs/commandExecutor.js +17 -0
- package/packages/client_build_tool/lib/commands/buildEs/config.js +12 -0
- package/packages/client_build_tool/lib/commands/buildLib/commandExecutor.js +17 -0
- package/packages/client_build_tool/lib/commands/buildLib/config.js +12 -0
- package/packages/client_build_tool/lib/commands/start/commandExecutor.js +13 -0
- package/packages/client_build_tool/lib/commands/start/config.js +12 -0
- package/packages/client_build_tool/lib/commands/start/deprecationHandler.js +10 -0
- package/packages/client_build_tool/lib/commands/start/errorHander.js +10 -0
- package/packages/client_build_tool/lib/commands/start/optionsProcesser.js +36 -0
- package/packages/client_build_tool/lib/commands/start/postProcesser.js +10 -0
- package/packages/client_build_tool/lib/commands/start/preProcesser.js +10 -0
- package/packages/client_build_tool/lib/commandsRouter.js +71 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/decidePublicPath.js +44 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/libAlias.js +31 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/nameTemplates.js +51 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +21 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/cssLoaders.js +16 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin.js +111 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/EFCPlugin.js +1 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ContributionGuide.md +11 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +136 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nSplit.md +95 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/README.md +25 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +29 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nDependency.js +99 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +81 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nModule.js +201 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +401 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +67 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +29 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +49 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +77 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +63 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +19 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +127 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RTLSplitPlugin.js +1 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +63 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +89 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtrSplit.md +34 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +15 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +155 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js +49 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/ExcludePlugin.js +58 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/custom_postcss_loaders/RTLSplitPlugin.js +139 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/devServerConfig.js +34 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/getCSSLoaders.js +30 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/jsLoaders.js +17 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +14 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +21 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +138 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +83 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/loaders/workerLoader.js +133 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/optimizationConfig.js +39 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/outputConfig.js +28 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configCopyThirdpartyFile.js +38 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +28 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +35 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +16 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +23 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +19 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +27 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +18 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/pluginConfigs/configUglifyCSSPlugin.js +15 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/plugins.js +39 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/postcssPlugins.js +36 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/resolvers.js +42 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/splitChunksConfig.js +12 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpack.dev.config.js +17 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackBuild.js +24 -0
- package/packages/client_build_tool/lib/shared/bundler/webpack/webpackConfig.js +50 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/doBasicRequiermentCheck.js +16 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/getCliPath.js +38 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/index.js +29 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/log.js +13 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/readArgsFormCommandLine.js +11 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/readOptionFormCommandLine.js +11 -0
- package/packages/client_build_tool/lib/shared/commands-utlis/spanSync.js +35 -0
- package/packages/client_build_tool/lib/shared/constants.js +33 -0
- package/packages/client_build_tool/lib/shared/schemas/applyValuesToShema.js +37 -0
- package/packages/client_build_tool/lib/shared/schemas/cliArgsToObject.js +37 -0
- package/packages/client_build_tool/lib/shared/schemas/defaultConfigValues.js +119 -0
- package/packages/client_build_tool/lib/shared/schemas/deprecatedOptionsHandler.js +65 -0
- package/packages/client_build_tool/lib/shared/schemas/getCWD.js +23 -0
- package/packages/client_build_tool/lib/shared/schemas/getNpmVersion.js +21 -0
- package/packages/client_build_tool/lib/shared/schemas/npmConfigToObject.js +32 -0
- package/packages/client_build_tool/lib/shared/schemas/oldDefaultConfigValues.js +480 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptions.js +55 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptionsForPackageJson.js +26 -0
- package/packages/client_build_tool/lib/shared/schemas/readOptionsOld.js +152 -0
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.crt +37 -0
- package/packages/client_build_tool/lib/shared/server/cert/Tsicsezwild-22-23.key +27 -0
- package/packages/client_build_tool/lib/shared/server/configWebpackDevMiddleware.js +40 -0
- package/packages/client_build_tool/lib/shared/server/corsHandleing.js +28 -0
- package/packages/client_build_tool/lib/shared/server/getIp.js +30 -0
- package/packages/client_build_tool/lib/shared/server/getServerURL.js +29 -0
- package/packages/client_build_tool/lib/shared/server/httpsOptions.js +53 -0
- package/packages/client_build_tool/lib/shared/server/initExpressApp.js +19 -0
- package/packages/client_build_tool/lib/shared/server/initialHTMLHandling.js +66 -0
- package/packages/client_build_tool/lib/shared/server/serveContextFiles.js +24 -0
- package/packages/client_build_tool/lib/shared/server/serverBywebpackDevMiddleware.js +40 -0
- package/packages/client_build_tool/lib/shared/server/startHttpServer.js +26 -0
- package/packages/client_build_tool/lib/shared/server/startHttpsServer.js +34 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/addHttp2Server.js +41 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/configWebpackDevMiddleware.js +44 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/devServerUtlis.js +1 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/mockApiSupport.js +19 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/webpackConfig.js +32 -0
- package/packages/client_build_tool/lib/shared/server/unwanted/websocketMockSetup.js +48 -0
- package/packages/client_build_tool/lib/shared/server/urlConcat.js +25 -0
- package/packages/client_build_tool/lib/shared/utils/utils.js +1 -0
package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
9
|
+
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
//import { getI18nFileUrlPathTemplate } from './I18nSplitPlugin/utils/getI18nFileUrlPathTemplate';
|
15
|
+
//import { getOptions } from '../utils';
|
16
|
+
//import I18nKeysIdentifer from './I18nSplitPlugin/I18nKeysIdentifer';
|
17
|
+
//import { replaceCssDirTemplateMapper } from './RtlSplitPlugin/replaceCssDirTemplate';
|
18
|
+
// const {
|
19
|
+
// css: { enableRTLSplit },
|
20
|
+
// i18n: { chunkSplitEnable }
|
21
|
+
// } = getOptions();
|
22
|
+
class ServiceWorkerPlugin {
|
23
|
+
constructor(options) {
|
24
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
25
|
+
this.fileName = options.fileName;
|
26
|
+
this.serviceWorkerPath = options.filePath;
|
27
|
+
this.writePath = options.exitPath;
|
28
|
+
this.replaceText = options.replaceText; // this.publicPaths = options.publicPaths;
|
29
|
+
}
|
30
|
+
|
31
|
+
isInitialChunk(chunk) {
|
32
|
+
if ('canBeInitial' in chunk) {
|
33
|
+
return chunk.canBeInitial();
|
34
|
+
}
|
35
|
+
|
36
|
+
return chunk.isInitial();
|
37
|
+
}
|
38
|
+
|
39
|
+
apply(compiler) {
|
40
|
+
compiler.hooks.emit.tap('ServiceWorkerPlugin', compilation => {
|
41
|
+
_fs.default.readFile(this.serviceWorkerPath, 'utf-8', (err, data) => {
|
42
|
+
if (err) {
|
43
|
+
throw new Error(err);
|
44
|
+
} else {
|
45
|
+
/* const extractedChunks = compilation.chunks.filter(chunk => {
|
46
|
+
if ('canBeInitial' in chunk) {
|
47
|
+
return chunk.canBeInitial();
|
48
|
+
}
|
49
|
+
return chunk.isInitial();
|
50
|
+
}); */
|
51
|
+
// let [js, css, , , i18nPublicPath] = this.publicPaths;
|
52
|
+
// let initialChunkUrls = [];
|
53
|
+
let allChunkUrls = [];
|
54
|
+
let allI18nAssets = [];
|
55
|
+
let entrypoint = compilation.entrypoints.get('main');
|
56
|
+
let initialChunkUrls = entrypoint.getFiles();
|
57
|
+
const cssDirTemplate = '@dir@';
|
58
|
+
/**
|
59
|
+
* NOTE:
|
60
|
+
* if chunkSplitEnable is false means,
|
61
|
+
* serviceWorker will get i18n files path for html
|
62
|
+
*/
|
63
|
+
// let initalI18nAssets = chunkSplitEnable
|
64
|
+
// ? entrypoint.chunks
|
65
|
+
// //.filter(chunk => I18nKeysIdentifer.isChunkHasI18n(chunk))
|
66
|
+
// .map(chunk =>
|
67
|
+
// getI18nFileUrlPathTemplate(
|
68
|
+
// compilation,
|
69
|
+
// chunk,
|
70
|
+
// this.i18nFileNameTemplate,
|
71
|
+
// '@locale@'
|
72
|
+
// )
|
73
|
+
// )
|
74
|
+
// : [];
|
75
|
+
|
76
|
+
let initalI18nAssets = []; //chunkSplitEnable &&
|
77
|
+
|
78
|
+
compilation.chunks.filter(c => !this.isInitialChunk(c)) //.filter(chunk => I18nKeysIdentifer.isChunkHasI18n(chunk))
|
79
|
+
.forEach(chunk => {
|
80
|
+
// let isInitial = this.isInitialChunk(chunk);
|
81
|
+
allChunkUrls = allChunkUrls.concat(chunk.files); // allI18nAssets.push(
|
82
|
+
// getI18nFileUrlPathTemplate(
|
83
|
+
// compilation,
|
84
|
+
// chunk,
|
85
|
+
// this.i18nFileNameTemplate,
|
86
|
+
// '@locale@'
|
87
|
+
// )
|
88
|
+
// );
|
89
|
+
});
|
90
|
+
/** Removing source map files from getting added */
|
91
|
+
|
92
|
+
initialChunkUrls = initialChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
93
|
+
allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map')); // if (enableRTLSplit) {
|
94
|
+
// initialChunkUrls = replaceCssDirTemplateMapper(
|
95
|
+
// initialChunkUrls,
|
96
|
+
// cssDirTemplate
|
97
|
+
// );
|
98
|
+
// allChunkUrls = replaceCssDirTemplateMapper(
|
99
|
+
// allChunkUrls,
|
100
|
+
// cssDirTemplate
|
101
|
+
// );
|
102
|
+
// }
|
103
|
+
|
104
|
+
let mod = data.replace(this.replaceText, `self.assets = ${JSON.stringify(initialChunkUrls.concat(initalI18nAssets))};self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
|
105
|
+
|
106
|
+
if (!_fs.default.existsSync(this.writePath)) {
|
107
|
+
_fs.default.mkdirSync(this.writePath, {
|
108
|
+
recursive: true
|
109
|
+
});
|
110
|
+
}
|
111
|
+
|
112
|
+
_fs.default.writeFileSync(_path.default.join(this.writePath, `${this.fileName}`), mod);
|
113
|
+
}
|
114
|
+
});
|
115
|
+
});
|
116
|
+
}
|
117
|
+
|
118
|
+
} // compiler.hooks.thisCompilation.tap('AddAssetPlugin', compilation => {
|
119
|
+
// compilation.hooks.processAssets.tapPromise(tapOptions, async () => {
|
120
|
+
// let source;
|
121
|
+
// if (typeof this.source === 'string') {
|
122
|
+
// if (compilation.getAsset(this.filePath)) {
|
123
|
+
// // Skip emitting the asset again because it's immutable
|
124
|
+
// return;
|
125
|
+
// }
|
126
|
+
// source = this.source;
|
127
|
+
// } else {
|
128
|
+
// source = await this.source(compilation);
|
129
|
+
// }
|
130
|
+
// compilation.emitAsset(this.filePath, new RawSource(source));
|
131
|
+
// });
|
132
|
+
// });
|
133
|
+
// getContentHash(compiler, compilation, source) {
|
134
|
+
// const { outputOptions } = compilation;
|
135
|
+
// const { hashDigest, hashDigestLength, hashFunction, hashSalt } =
|
136
|
+
// outputOptions;
|
137
|
+
// const hash = compiler.webpack.util.createHash(
|
138
|
+
// /** @type {string} */ (hashFunction)
|
139
|
+
// );
|
140
|
+
// if (hashSalt) {
|
141
|
+
// hash.update(hashSalt);
|
142
|
+
// }
|
143
|
+
// hash.update(source);
|
144
|
+
// const fullContentHash = hash.digest(hashDigest);
|
145
|
+
// return fullContentHash.toString().slice(0, hashDigestLength);
|
146
|
+
// }
|
147
|
+
// const contentHash = CopyPlugin.getContentHash(
|
148
|
+
// compiler,
|
149
|
+
// compilation,
|
150
|
+
// source.buffer()
|
151
|
+
// );
|
152
|
+
//hash same as index.html file ??
|
153
|
+
|
154
|
+
|
155
|
+
exports.default = ServiceWorkerPlugin;
|
package/packages/client_build_tool/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin.js
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
9
|
+
|
10
|
+
var _webpack = require("webpack");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
/* eslint-disable class-methods-use-this */
|
15
|
+
// import { RawSource } from 'webpack-sources';
|
16
|
+
const pluginName = 'UglifyCSSPlugin'; // TODO: Check for css minimizer plugin
|
17
|
+
|
18
|
+
class UglifyCSSPlugin {
|
19
|
+
apply(compiler) {
|
20
|
+
const {
|
21
|
+
RawSource
|
22
|
+
} = compiler.webpack.sources;
|
23
|
+
compiler.hooks.emit.tap(pluginName, compilation => {
|
24
|
+
compilation.hooks.processAssets.tapAsync({
|
25
|
+
name: pluginName,
|
26
|
+
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
27
|
+
}, assets => {
|
28
|
+
Object.keys(assets).filter(filename => /\.css$/.test(filename)).forEach(filename => {
|
29
|
+
try {
|
30
|
+
let asset = compilation.assets[filename].source();
|
31
|
+
|
32
|
+
if (typeof asset !== 'string') {
|
33
|
+
asset = asset.toString();
|
34
|
+
}
|
35
|
+
|
36
|
+
const result = _uglifycss.default.processString(asset);
|
37
|
+
|
38
|
+
compilation.updateAsset(filename, new RawSource(result));
|
39
|
+
} catch (e) {
|
40
|
+
compilation.errors.push(e);
|
41
|
+
}
|
42
|
+
});
|
43
|
+
});
|
44
|
+
});
|
45
|
+
}
|
46
|
+
|
47
|
+
}
|
48
|
+
|
49
|
+
exports.default = UglifyCSSPlugin;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
exports.excludeEmptyCheckPlugin = excludeEmptyCheckPlugin;
|
8
|
+
|
9
|
+
var _postcss = _interopRequireDefault(require("postcss"));
|
10
|
+
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
12
|
+
|
13
|
+
const ExcludePlugin = opts => {
|
14
|
+
const {
|
15
|
+
plugins,
|
16
|
+
exclude
|
17
|
+
} = opts;
|
18
|
+
return {
|
19
|
+
postcssPlugin: 'postcss-dark-theme-class',
|
20
|
+
|
21
|
+
Once(root, {
|
22
|
+
result
|
23
|
+
}) {
|
24
|
+
const inputFile = root.source.input.file;
|
25
|
+
const isIgnoredFile = exclude.some(file => inputFile.indexOf(file) !== -1);
|
26
|
+
|
27
|
+
if (!isIgnoredFile) {
|
28
|
+
const handler = response => response.messages.forEach(msg => result.messages.push(msg));
|
29
|
+
|
30
|
+
return (0, _postcss.default)(plugins).process(root, {
|
31
|
+
from: undefined
|
32
|
+
}).then(handler);
|
33
|
+
}
|
34
|
+
|
35
|
+
return root;
|
36
|
+
}
|
37
|
+
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
ExcludePlugin.postcss = true;
|
42
|
+
var _default = ExcludePlugin;
|
43
|
+
exports.default = _default;
|
44
|
+
|
45
|
+
function excludeEmptyCheckPlugin({
|
46
|
+
enable,
|
47
|
+
exclude,
|
48
|
+
plugins
|
49
|
+
}) {
|
50
|
+
if (!enable) {
|
51
|
+
return [];
|
52
|
+
}
|
53
|
+
|
54
|
+
return exclude.length === 0 ? plugins : [ExcludePlugin({
|
55
|
+
exclude,
|
56
|
+
plugins
|
57
|
+
})];
|
58
|
+
}
|
@@ -0,0 +1,139 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.separateRtlAndLtr = separateRtlAndLtr;
|
7
|
+
exports.separateSingleDir = separateSingleDir;
|
8
|
+
|
9
|
+
var postcss = _interopRequireWildcard(require("postcss"));
|
10
|
+
|
11
|
+
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); }
|
12
|
+
|
13
|
+
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; }
|
14
|
+
|
15
|
+
/* eslint-disable no-param-reassign */
|
16
|
+
const oppositeDir = {
|
17
|
+
ltr: 'rtl',
|
18
|
+
rtl: 'ltr'
|
19
|
+
};
|
20
|
+
|
21
|
+
function compareSelector(selector1, selector2) {
|
22
|
+
// console.log({ selector1, selector2 }, selector1 === selector2);
|
23
|
+
return selector1 === selector2;
|
24
|
+
}
|
25
|
+
|
26
|
+
const directionRegexs = {
|
27
|
+
ltr: /\[dir=ltr\]/,
|
28
|
+
rtl: /\[dir=rtl\]/
|
29
|
+
};
|
30
|
+
|
31
|
+
const getRegex = dir => directionRegexs[dir];
|
32
|
+
|
33
|
+
const getOppositeRegex = dir => getRegex(oppositeDir[dir]);
|
34
|
+
|
35
|
+
function selectorMinifySameDir(selector, direction) {
|
36
|
+
// NOTE: if this rule is same dir as current need
|
37
|
+
// then we can just remove that [dir=ltr] or [dir=rtl]
|
38
|
+
// it just for minimaze selector
|
39
|
+
const regex = getRegex(direction);
|
40
|
+
return selector.replace(regex, '').trim();
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* this funtion will remove given rule,
|
44
|
+
* if given selector and it's previous sibiling rule selector are same
|
45
|
+
* current rule properties will move to previous sibiling rule.
|
46
|
+
* @param {Rule} rule current rule
|
47
|
+
*/
|
48
|
+
|
49
|
+
|
50
|
+
function mergeIfSameSelector(rule) {
|
51
|
+
// NOTE: to merge dublicate selector rules
|
52
|
+
const prev = rule.prev();
|
53
|
+
|
54
|
+
if (prev && compareSelector(prev.selector, rule.selector)) {
|
55
|
+
rule.each(decl => {
|
56
|
+
prev.append(decl);
|
57
|
+
});
|
58
|
+
rule.remove();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* this funtion will remove given rule,
|
63
|
+
* if given selector and it's previous sibiling rule selector are same
|
64
|
+
* current rule properties will move to previous sibiling rule.
|
65
|
+
* @param {Rule} rule current rule
|
66
|
+
*/
|
67
|
+
|
68
|
+
|
69
|
+
function removeIfOppsiteDirRule(rule, direction, rootOptions) {
|
70
|
+
// console.log({ rule, type: rule.type });
|
71
|
+
const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
|
72
|
+
// and compain normal selector with it, In this case
|
73
|
+
// we just a have to remove that selector only not full rule
|
74
|
+
|
75
|
+
const oppositeDirRegex = getOppositeRegex(direction);
|
76
|
+
let remainingSelectors = selectors.filter(selector => !oppositeDirRegex.test(selector));
|
77
|
+
|
78
|
+
if (!rootOptions.disableMinifySelector) {
|
79
|
+
remainingSelectors = remainingSelectors.map(selector => selectorMinifySameDir(selector, direction));
|
80
|
+
}
|
81
|
+
|
82
|
+
if (remainingSelectors.length) {
|
83
|
+
rule.selector = remainingSelectors.join(', ');
|
84
|
+
} else {
|
85
|
+
// NOTE: every selector is opposite dir then we have to remove the rule
|
86
|
+
rule.remove();
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
function removeIfOppsiteDirKeyframe(rule, direction) {
|
91
|
+
const name = rule.params;
|
92
|
+
const keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
|
93
|
+
|
94
|
+
if (keyFrameDirName === oppositeDir[direction]) {
|
95
|
+
// console.log({ m: 'removed', keyFrameName: rule.params });
|
96
|
+
rule.remove();
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
function separateSingleDir(root, direction, rootOptions) {
|
101
|
+
root.walkRules(rule => {
|
102
|
+
removeIfOppsiteDirRule(rule, direction, rootOptions);
|
103
|
+
mergeIfSameSelector(rule);
|
104
|
+
});
|
105
|
+
root.walkAtRules(rule => {
|
106
|
+
removeIfOppsiteDirKeyframe(rule, direction);
|
107
|
+
});
|
108
|
+
return root;
|
109
|
+
}
|
110
|
+
|
111
|
+
function separateRtlAndLtr(css, rootOptions) {
|
112
|
+
// let processor = postcss([]).process(css);
|
113
|
+
const root = postcss.parse(css); // let { root } = processor;
|
114
|
+
// console.log(processor, root);
|
115
|
+
// NOTE: I did first rtl then ltr , Because for ltr I use original root ref
|
116
|
+
|
117
|
+
const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions); // console.log('############################');
|
118
|
+
|
119
|
+
const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
|
120
|
+
return {
|
121
|
+
ltrRoot,
|
122
|
+
rtlRoot,
|
123
|
+
ltr: ltrRoot.toString(),
|
124
|
+
rtl: rtlRoot.toString()
|
125
|
+
};
|
126
|
+
} // NOTE: to test in https://astexplorer.net/
|
127
|
+
// you can test with sample input https://astexplorer.net/#/gist/a892a509eb585099355ef53ef094f836/1ca70d5f7af3b88ca4910296e12f118e9712c874
|
128
|
+
// export default postcss.plugin('postcss-rtl-remove', (options = {}) =>
|
129
|
+
// // Work with options here
|
130
|
+
// root => {
|
131
|
+
// const rtlRoot = separateSingleDir(root.clone(), 'rtl');
|
132
|
+
// const ltrRoot = separateSingleDir(root, 'ltr');
|
133
|
+
// // root.append(postcss.comment({ text: 'comment' }));
|
134
|
+
// root.append(postcss.comment({ text: 'this is spliting part ' }));
|
135
|
+
// root.append(rtlRoot);
|
136
|
+
// //console.log({root, roots:root+""}, root+"")
|
137
|
+
// // Transform CSS AST here
|
138
|
+
// }
|
139
|
+
// );
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.devServerConfig = devServerConfig;
|
7
|
+
|
8
|
+
var _path = require("path");
|
9
|
+
|
10
|
+
var _constants = require("../../constants");
|
11
|
+
|
12
|
+
// import { httpsOptions } from '../../server/httpsOptions';
|
13
|
+
function devServerConfig(options) {
|
14
|
+
const {
|
15
|
+
context,
|
16
|
+
server
|
17
|
+
} = options;
|
18
|
+
const {
|
19
|
+
port
|
20
|
+
} = server;
|
21
|
+
return {
|
22
|
+
static: {
|
23
|
+
directory: (0, _path.join)(_constants.appPath, context)
|
24
|
+
},
|
25
|
+
allowedHosts: 'all',
|
26
|
+
// https: httpsOptions(options),
|
27
|
+
client: {
|
28
|
+
logging: 'error',
|
29
|
+
overlay: true
|
30
|
+
},
|
31
|
+
// contentBase: "app"
|
32
|
+
port
|
33
|
+
};
|
34
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getCSSLoaders = getCSSLoaders;
|
7
|
+
|
8
|
+
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
9
|
+
|
10
|
+
var _getCssLoaderOptions = require("./loaderConfigs/getCssLoaderOptions");
|
11
|
+
|
12
|
+
var _postcssPlugins = require("./postcssPlugins");
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
function getCSSLoaders(options) {
|
17
|
+
const neededPostCssPlugins = (0, _postcssPlugins.postcssPlugins)(options);
|
18
|
+
const cssLoaderOptions = (0, _getCssLoaderOptions.getCssLoaderOptions)(options);
|
19
|
+
return [_miniCssExtractPlugin.default.loader, {
|
20
|
+
loader: 'css-loader',
|
21
|
+
options: cssLoaderOptions
|
22
|
+
}, neededPostCssPlugins.length && {
|
23
|
+
loader: 'postcss-loader',
|
24
|
+
options: {
|
25
|
+
postcssOptions: {
|
26
|
+
plugins: neededPostCssPlugins
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}].filter(Boolean);
|
30
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.jsLoaders = jsLoaders;
|
7
|
+
|
8
|
+
var _babelLoaderConfig = require("./loaderConfigs/babelLoaderConfig");
|
9
|
+
|
10
|
+
function jsLoaders(options) {
|
11
|
+
return [{
|
12
|
+
test: /\.js$/,
|
13
|
+
exclude: /node_modules/,
|
14
|
+
use: [(0, _babelLoaderConfig.babelLoaderConfig)(options)] // include: path.join(appPath, folder)
|
15
|
+
|
16
|
+
}];
|
17
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.assetLoaders = assetLoaders;
|
7
|
+
|
8
|
+
var _configsAssetsLoaders = require("./configsAssetsLoaders");
|
9
|
+
|
10
|
+
function assetLoaders(options) {
|
11
|
+
// const { enableChunkHash } = options;
|
12
|
+
// const nameTemplate = createNameTemplate(enableChunkHash);
|
13
|
+
return [(0, _configsAssetsLoaders.configImageLoader)(options), (0, _configsAssetsLoaders.configFontLoader)(options), (0, _configsAssetsLoaders.configSVGLoader)(options), (0, _configsAssetsLoaders.configAudioLoader)(options), (0, _configsAssetsLoaders.configVideoLoader)(options)];
|
14
|
+
}
|
package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.babelLoaderConfig = babelLoaderConfig;
|
7
|
+
const supportedBrowserVersions = ['last 3 Chrome versions', 'last 3 Firefox versions', 'last 3 Edge versions', 'last 3 Safari versions'];
|
8
|
+
|
9
|
+
function babelLoaderConfig(options) {
|
10
|
+
return {
|
11
|
+
loader: 'babel-loader',
|
12
|
+
options: {
|
13
|
+
presets: [[require.resolve('@babel/preset-env'), {
|
14
|
+
modules: false,
|
15
|
+
useBuiltIns: 'usage',
|
16
|
+
corejs: 3,
|
17
|
+
targets: {
|
18
|
+
browsers: supportedBrowserVersions
|
19
|
+
}
|
20
|
+
}], require.resolve('@babel/preset-react')],
|
21
|
+
cacheDirectory: true
|
22
|
+
}
|
23
|
+
};
|
24
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configHtmlTemplateLoader = configHtmlTemplateLoader;
|
7
|
+
|
8
|
+
function configHtmlTemplateLoader(options) {
|
9
|
+
return {
|
10
|
+
test: /\.tmpl$/,
|
11
|
+
use: [{
|
12
|
+
loader: 'html-loader',
|
13
|
+
options: {
|
14
|
+
minimize: true
|
15
|
+
}
|
16
|
+
}]
|
17
|
+
};
|
18
|
+
}
|
package/packages/client_build_tool/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.configWebWorkerLoader = configWebWorkerLoader;
|
7
|
+
|
8
|
+
var _nameTemplates = require("../common/nameTemplates");
|
9
|
+
|
10
|
+
function configWebWorkerLoader(options) {
|
11
|
+
return {
|
12
|
+
test: /\.worker.js$/,
|
13
|
+
use: {
|
14
|
+
loader: require.resolve('../loaders/workerLoader.js'),
|
15
|
+
options: {
|
16
|
+
esModule: true,
|
17
|
+
filename: (0, _nameTemplates.nameTemplates)('workerjs', options)
|
18
|
+
}
|
19
|
+
}
|
20
|
+
};
|
21
|
+
}
|