@zohodesk/react-cli 0.0.1-exp.160.3 → 0.0.1-exp.162.2

Sign up to get free protection for your applications and to get access to all the features.
package/.eslintrc.js CHANGED
@@ -108,7 +108,7 @@ let commonConfigs = {
108
108
  'comma-dangle': [logLevel],
109
109
  'comma-spacing': [logLevel],
110
110
  'func-call-spacing': [logLevel],
111
- indent: [logLevel, 2, { SwitchCase: 1 }],
111
+ indent: ['off', 2, { SwitchCase: 1 }],
112
112
  'jsx-quotes': [logLevel, 'prefer-single'],
113
113
  'key-spacing': [logLevel],
114
114
  'keyword-spacing': [logLevel],
package/README.md CHANGED
@@ -1,39 +1,111 @@
1
1
  # React CLI
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
+
5
+ # 0.0.1-exp.162.2
6
+
7
+ - **Optimazation:-**
8
+ - double time minimize optimazation
9
+
10
+ # 0.0.1-beta.162.1
11
+
12
+ - **Issue Fix:-**
13
+ - if git not installed react-cli throws error for any command due to `getCurrentBranch` in `shemas/index.js` now fixed
14
+
15
+ # 0.0.1-beta.161.1
16
+
17
+ - **Features :-**
18
+ - feature added for pre process logic
19
+ - tailer made requirement for preprocess, just write node js file
20
+ - mention file in `"react-cli" => "preprocess" => "runner"`
21
+ - option parse logic added for react-cli (exprimental)
22
+
23
+ # 0.0.1-beta.161
24
+
25
+ - **Features :-**
26
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" => "templateFilePath"`
27
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
28
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
29
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
30
+ - `assetsType` are `js`, `css`, `i18n`
31
+ - `lang` this argument only works when `i18n` is `assetsType`
32
+ - feature added for efc `cdnStatement`
33
+ - **Issue fixes:-**
34
+ - css classname hash change issue fix
35
+ - debug package conflit issue fix in nock in (react-cli test)
36
+ - manifest.json css file name correction issue for rtl and ltr
37
+
38
+ # 0.0.1-exp.161.2
39
+
40
+ - Features
41
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
42
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
43
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
44
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
45
+ - `assetsType` are `js`, `css`, `i18n`
46
+ - `lang` this argument only works when `i18n` is `assetsType`
47
+
48
+ # 0.0.1-exp.161.1
49
+
50
+ - Features
51
+ - feature added for efc `cdnStatement`
52
+ - Issue fixes:-
53
+ - css classname hash change issue fix
54
+ - debug package conflit issue fix in nock in (react-cli test)npm i @zohodesk/virtualizer
55
+ - manifest.json css file name correction issue for rtl and ltr
56
+
4
57
  # 0.0.1-beta.160
58
+
5
59
  - @zohodesk/normalizer package version updated to 1.0.2
60
+
6
61
  # 0.0.1-beta.159
62
+
7
63
  - @zohodesk/datetimejs package updated to beta.7
64
+
65
+ # 0.0.1-exp.159
66
+
67
+ - isse fix:-
68
+ - when rtl ltr css split enable manifest json css filename keys comes with hash .
69
+
8
70
  # 0.0.1-beta.158
9
- - Removing source map files from service worker caching.
71
+
72
+ - Removing source map files from service worker caching.
73
+
10
74
  # 0.0.1-beta.157
11
- - Experimental version issue fix(Dummy version removed)
75
+
76
+ - Experimental version issue fix(Dummy version removed)
77
+
12
78
  # 0.0.1-beta.156
13
- - ReportPublish issue fix
79
+
80
+ - ReportPublish issue fix
14
81
 
15
82
  # 0.0.1-beta.155
16
- - get impacted library source files option added
83
+
84
+ - get impacted library source files option added
17
85
 
18
86
  # 0.0.1-beta.154
19
- - mockPrefix option for mock url prefix change
20
- - Issue fix:-
21
- - un wanted {{--js-smap}} in inital html without enable smap in build
87
+
88
+ - mockPrefix option for mock url prefix change
89
+ - Issue fix:-
90
+ - un wanted {{--js-smap}} in inital html without enable smap in build
22
91
 
23
92
  # 0.0.1-beta.153
93
+
24
94
  - Vendor include array added
25
95
  - If you need to include any thrid party js in vendor we can use this array
26
96
 
27
97
  # 0.0.1-beta.152
98
+
28
99
  impact servise related changes:-
100
+
29
101
  - nowatchstart option added. will be used like `react-cli nowatchstart <...options>` this will be used for src file changes no need to reflect (or no need to rebulid on file changes)
30
102
  - cssselector_zip option added. will be used like `--cssselector-zip=selectormapping.zip`
31
103
  only work in two ways
32
104
  1. `react-cli start --disable-watch --cssselector-zip=selectormapping.zip` app start command with `--disable-watch` flag and your usaul options
33
105
  2. `react-cli nowatchstart --cssselector-zip=selectormapping.zip` app start command's usaul options
34
106
  #### Urls are:-
35
- Below express path are added, For download zip files and
36
- - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
107
+ Below express path are added, For download zip files and
108
+ - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
37
109
  - `/zips/build.zip` build zip file (contains bundled all files)
38
110
 
39
111
  # 0.0.1-beta.151
package/bin/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  let path = require('path');
4
4
  let os = require('os');
5
- let { spawnSync } = require('child_process');
5
+ let { spawnSync, spawn } = require('child_process');
6
6
  let { getOptions } = require('../lib/utils/index.js');
7
7
 
8
8
  let { log } = require('../lib/utils');
@@ -42,8 +42,53 @@ let babel = getCliPath('babel');
42
42
  let propertyToJson = getCliPath('propertyToJson');
43
43
  let esLint = getCliPath('eslint');
44
44
 
45
+ let preprocesserPath = options.preprocessor.runner
46
+ ? path.join(process.cwd(), options.preprocessor.runner)
47
+ : '';
48
+
49
+ // console.log(
50
+ // 'options.app.preprocessor',
51
+ // options.preprocessor.runner,
52
+ // preprocesserPath
53
+ // );
54
+ if (preprocesserPath) {
55
+ // eslint-disable-next-line default-case
56
+ switch (option) {
57
+ case 'start':
58
+ case 'docs':
59
+ spawn(nodemon, [preprocesserPath], {
60
+ stdio: 'inherit',
61
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
62
+ });
63
+ // NOTE: it's ok if we not close this here
64
+ // Because when node server stops this program willbe closed So this nodemon will be killed as well
65
+ break;
66
+ case 'nowatchstart':
67
+ case 'build:library:es':
68
+ case 'build:component:es':
69
+ case 'build:library:cmjs':
70
+ case 'build:component:cmjs':
71
+ spawnSync('node', [preprocesserPath], {
72
+ stdio: 'inherit',
73
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
74
+ });
75
+ break;
76
+ }
77
+ }
78
+
45
79
  let result;
46
80
  switch (option) {
81
+ case 'preprocessor':
82
+ if (preprocesserPath) {
83
+ result = spawnSync(nodemon, [preprocesserPath], {
84
+ stdio: 'inherit',
85
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
86
+ });
87
+ process.exit(result.status);
88
+ } else {
89
+ console.error('preProcessor not exists ');
90
+ }
91
+ break;
47
92
  case 'lint-setup': {
48
93
  result = spawnSync(
49
94
  'node',
@@ -219,11 +264,14 @@ switch (option) {
219
264
  webpack,
220
265
  [
221
266
  '--config',
222
- require.resolve('../lib/configs/webpack.prod.config.js')
267
+ require.resolve('../lib/configs/webpack.prod.config.js'),
268
+ '--progress',
269
+ '--profile'
223
270
  ].concat(args),
224
271
  { stdio: 'inherit' }
225
272
  );
226
273
 
274
+ // console.log(result);
227
275
  process.exit(result.status);
228
276
  break;
229
277
 
@@ -0,0 +1,3 @@
1
+ Suggestions :
2
+
3
+ 1. 'lint-setup', 'add-lint-scripts' not need to exposed
@@ -0,0 +1,18 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <title>mock api</title>
7
+ </head>
8
+ <body>
9
+ <h1>We are going to see how to use mock api</h1>
10
+ <ul>
11
+ <li>
12
+ Step 1:-
13
+ you need to start the app with "react-cli"."app"."server"."hasMock" as "true" in package.json
14
+ <code>npm run start --app-port=9090</code>
15
+ </li>
16
+ </ul>
17
+ </body>
18
+ </html>
@@ -0,0 +1,5 @@
1
+ # We are going to see how to use `Mock api`
2
+
3
+ - Step 1:-
4
+ you need to start the app with **"react-cli"."app"."server"."hasMock"** as `true` and **"react-cli"."app"."server"."hasMock"** as `true` in package.json <code>npm run start --app-port=9090</code>
5
+ - Step 2:- you need to start the app with **"react-cli"."app"."server"."hasMock"** as `true` in package.json <code>npm run start --app-port=9090</code>
@@ -2,9 +2,17 @@
2
2
 
3
3
  var _path = _interopRequireDefault(require("path"));
4
4
 
5
+ var _libAlias = require("./libAlias");
6
+
5
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
8
 
7
- let appPath = process.cwd();
9
+ let appPath = process.cwd(); // '^@root(.*)$': '<rootDir>/src$1',
10
+ // '^@components(.*)$': '<rootDir>/src/components$1',
11
+
12
+ let moduleNameMapper = Object.keys(_libAlias.libAlias).reduce((previousValue, key) => {
13
+ previousValue[`^${key}(.*)$`] = `${_libAlias.libAlias[key]}$1`;
14
+ return previousValue;
15
+ }, {});
8
16
  let commonConfig = {
9
17
  coverageReporters: ['json', 'html', 'json-summary', 'text'],
10
18
  collectCoverage: true,
@@ -14,10 +22,11 @@ let commonConfig = {
14
22
  '^.+\\.css$': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'cssPreprocessor.js'),
15
23
  '^(?!.*\\.(js|jsx|css|json)$)': _path.default.resolve(__dirname, '..', 'jest', 'preProcessors', 'otherFilesPreprocessor.js')
16
24
  },
17
- moduleNameMapper: {
25
+ moduleNameMapper: { ...moduleNameMapper,
18
26
  '\\.(css|less)$': 'identity-obj-proxy'
19
27
  },
20
- transformIgnorePatterns: ['/node_modules.*?.js$'],
28
+ transformIgnorePatterns: ['/node_modules/(?!(@zohodesk)/)'],
29
+ // transformIgnorePatterns: ['/node_modules.*?.js$'],
21
30
  moduleFileExtensions: ['js'],
22
31
  setupFiles: [_path.default.resolve(appPath, '__testUtils__', 'globals.js'), _path.default.resolve(__dirname, '..', 'jest', 'setup.js')],
23
32
  globals: {
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.libAlias = void 0;
7
+ // the reason for alias at the time was code tree shaking
8
+ // tree shaking was most compactable with ES module system
9
+ // FIXME: But there is a posiblity when these package does not have lib,
10
+ // app will work because of alias, But may be jest won't work because of not alais
11
+ // So need to think about use alais in jest
12
+ const libAlias = {
13
+ '@zohodesk/components/lib': '@zohodesk/components/es',
14
+ // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
15
+ '@zohodesk/dot/lib': '@zohodesk/dot/es',
16
+ '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
17
+ '@zohodesk/icons/lib': '@zohodesk/icons/es',
18
+ '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
19
+ '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
20
+ '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
21
+ '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
22
+ '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
23
+ '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
24
+ '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
25
+ '@zohodesk/storage/lib': '@zohodesk/storage/es',
26
+ '@zohodesk/svg/lib': '@zohodesk/svg/es',
27
+ '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
28
+ '@zohodesk/variables/lib': '@zohodesk/variables/es',
29
+ '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
30
+ };
31
+ exports.libAlias = libAlias;
@@ -10,6 +10,8 @@ var _pluginUtils = require("../pluginUtils");
10
10
 
11
11
  var _loaderUtils = require("../loaderUtils");
12
12
 
13
+ var _libAlias = require("./libAlias");
14
+
13
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
16
 
15
17
  let options = (0, _utils.getOptions)();
@@ -55,6 +57,9 @@ module.exports = {
55
57
  entry: (0, _common.getEntries)(options, 'dev'),
56
58
  devtool: sourcemap,
57
59
  mode: 'development',
60
+ watchOptions: {
61
+ ignored: /node_modules.(?!@zohodesk)/
62
+ },
58
63
  output,
59
64
  stats: options.app.disableWatch ? 'errors-only' : {
60
65
  children: false
@@ -127,25 +132,7 @@ module.exports = {
127
132
  },
128
133
  resolve: {
129
134
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
130
- alias: disableES5Transpile ? {
131
- '@zohodesk/components/lib': '@zohodesk/components/es',
132
- // "@zohodesk/zc-custom/lib": "@zohodesk/zc-custom/es",
133
- '@zohodesk/dot/lib': '@zohodesk/dot/es',
134
- '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
135
- '@zohodesk/icons/lib': '@zohodesk/icons/es',
136
- '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
137
- '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
138
- '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
139
- '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
140
- '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
141
- '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
142
- '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
143
- '@zohodesk/storage/lib': '@zohodesk/storage/es',
144
- '@zohodesk/svg/lib': '@zohodesk/svg/es',
145
- '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
146
- '@zohodesk/variables/lib': '@zohodesk/variables/es',
147
- '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
148
- } : {}
135
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
149
136
  },
150
137
  resolveLoader: {
151
138
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
@@ -10,11 +10,12 @@ var _pluginUtils = require("../pluginUtils");
10
10
 
11
11
  var _loaderUtils = require("../loaderUtils");
12
12
 
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ var _libAlias = require("./libAlias");
14
+
15
+ var _terserWebpackPlugin = _interopRequireDefault(require("terser-webpack-plugin"));
14
16
 
15
- const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
17
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
18
 
17
- const smp = new SpeedMeasurePlugin();
18
19
  let options = (0, _utils.getOptions)();
19
20
  let {
20
21
  app: {
@@ -67,7 +68,11 @@ if (isDevelopment) {
67
68
  }
68
69
 
69
70
  let shouldRemovePropTypes = !isDevelopment && removePropTypes;
70
- module.exports = smp.wrap({
71
+ const useEsbulid = false; // const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
72
+ // const smp = new SpeedMeasurePlugin();
73
+ // module.exports = smp.wrap({
74
+
75
+ module.exports = {
71
76
  entry: (0, _common.getEntries)(options, 'production'),
72
77
  devtool: isDevelopment ? 'cheap-module-source-map' : enableSMap ? 'hidden-source-map' : 'none',
73
78
  mode: 'production',
@@ -79,12 +84,20 @@ module.exports = smp.wrap({
79
84
  },
80
85
  concatenateModules: true,
81
86
  minimize: true,
87
+ // by default if minimize: true in webpack minimize then webpack automaticaly add TerserPlugin,
88
+ // So we are overrideing it.
89
+ minimizer: [new _terserWebpackPlugin.default({
90
+ cache: true,
91
+ parallel: true,
92
+ sourceMap: isDevelopment && enableSMap,
93
+ exclude: /\/smap/
94
+ })],
82
95
  moduleIds: 'named'
83
96
  },
84
97
  stats: {
85
98
  children: false,
86
99
  colors: true,
87
- excludeAssets: /i18n|\.map$/,
100
+ excludeAssets: /./,
88
101
  warningsFilter: /\[mini-css-extract-plugin\]/
89
102
  },
90
103
  plugins: (0, _pluginUtils.getProdPlugins)(options, output.publicPath),
@@ -93,7 +106,15 @@ module.exports = smp.wrap({
93
106
  strictExportPresence: true,
94
107
  rules: [{
95
108
  test: /\.js$/,
96
- use: [{
109
+ use: [useEsbulid && {
110
+ loader: 'esbuild-loader',
111
+ options: {
112
+ loader: 'jsx',
113
+ // Remove this if you're not using JSX
114
+ target: 'es2015' // Syntax to compile to (see options below for possible values)
115
+
116
+ }
117
+ }, !useEsbulid && {
97
118
  loader: 'babel-loader',
98
119
  options: {
99
120
  presets: [[require.resolve('@babel/preset-env'), disableES5Transpile ? {
@@ -116,7 +137,8 @@ module.exports = smp.wrap({
116
137
  }] : null].filter(Boolean),
117
138
  cacheDirectory: true
118
139
  }
119
- }],
140
+ }].filter(Boolean),
141
+ // include: path.join(appPath, folder)
120
142
  include: module => {
121
143
  let srcPath = _path.default.join(appPath, folder);
122
144
 
@@ -133,7 +155,7 @@ module.exports = smp.wrap({
133
155
  exclude: /\.module\.css$/,
134
156
  use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, '[local]', false, null)
135
157
  } : null, {
136
- test: seperateCssModules ? /\.module\.css$/ : /(\.module)?\.css$/,
158
+ test: seperateCssModules ? /\.module\.css$/ : /\.css$/,
137
159
  use: (0, _loaderUtils.getCSSLoaders)(hasRTL, rtlExclude, false, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix)
138
160
  }, {
139
161
  test: /\.jpe?g$|\.gif$|\.png$/,
@@ -197,27 +219,9 @@ module.exports = smp.wrap({
197
219
  },
198
220
  resolve: {
199
221
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
200
- alias: disableES5Transpile ? {
201
- '@zohodesk/components/lib': '@zohodesk/components/es',
202
- // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
203
- '@zohodesk/dot/lib': '@zohodesk/dot/es',
204
- '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
205
- '@zohodesk/icons/lib': '@zohodesk/icons/es',
206
- '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
207
- '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
208
- '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
209
- '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
210
- '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
211
- '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
212
- '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
213
- '@zohodesk/storage/lib': '@zohodesk/storage/es',
214
- '@zohodesk/svg/lib': '@zohodesk/svg/es',
215
- '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
216
- '@zohodesk/variables/lib': '@zohodesk/variables/es',
217
- '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
218
- } : {}
222
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
219
223
  },
220
224
  resolveLoader: {
221
225
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
222
226
  }
223
- });
227
+ };
@@ -55,6 +55,7 @@ let getDevPlugins = (options, publicPath) => {
55
55
  },
56
56
  efc: {
57
57
  hasEFC: newOptionForEnableEFC,
58
+ templateFilePath,
58
59
  nameScope: efcNameSpace,
59
60
  localeAttr: efcLocaleAttr
60
61
  },
@@ -162,6 +163,7 @@ let getDevPlugins = (options, publicPath) => {
162
163
  plugins.push(new _plugins.EFCPlugin({
163
164
  isDevelopment: true,
164
165
  i18nManifestFileName,
166
+ templateFilePath,
165
167
  i18nFileNameTemplate,
166
168
  serverUrl: publicPath,
167
169
  entryPointName: 'efc',
@@ -11,6 +11,8 @@ var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
12
  var _webpack = _interopRequireDefault(require("webpack"));
13
13
 
14
+ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
15
+
14
16
  var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
15
17
 
16
18
  var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
@@ -33,8 +35,10 @@ var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
33
35
 
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
35
37
 
36
- // import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
38
+ // import { ESBuildMinifyPlugin } from 'esbuild-loader';
39
+ const useEsbulid = false; // console.log('build is runnnig');
37
40
  // eslint-disable-next-line no-unused-vars
41
+
38
42
  let getProdPlugins = (options, publicPath = '') => {
39
43
  let {
40
44
  enableChunkHash,
@@ -71,6 +75,7 @@ let getProdPlugins = (options, publicPath = '') => {
71
75
  const {
72
76
  hasEFC: newOptionForEnableEFC,
73
77
  nameScope: efcNameSpace,
78
+ templateFilePath,
74
79
  localeAttr: efcLocaleAttr
75
80
  } = options.efc;
76
81
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
@@ -79,8 +84,7 @@ let getProdPlugins = (options, publicPath = '') => {
79
84
  const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
80
85
  let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
81
86
  enableChunkHash = !isDevelopment && enableChunkHash;
82
- let plugins = [// new CaseSensitivePathsPlugin(),
83
- new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
87
+ let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
84
88
  __TEST__: false,
85
89
  __DEVELOPMENT__: false,
86
90
  __LOCAL_PRODUCTION__: isDevelopment,
@@ -93,7 +97,7 @@ let getProdPlugins = (options, publicPath = '') => {
93
97
  // ignoreOrder: true,
94
98
  filename: cssLTRFileNameTempalte,
95
99
  chunkFilename: cssLTRFileNameTempalte
96
- }), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
100
+ }), new _plugins.ResourceHintsPlugin(), !useEsbulid && new _plugins.UglifyCSSPlugin()].filter(Boolean);
97
101
 
98
102
  if (enableRTLSplit) {
99
103
  plugins.push(new _RtlCssPlugin.RtlCssPlugin({
@@ -166,6 +170,7 @@ let getProdPlugins = (options, publicPath = '') => {
166
170
  isDevelopment,
167
171
  serverUrl: publicPath,
168
172
  i18nFileNameTemplate,
173
+ templateFilePath,
169
174
  i18nManifestFileName,
170
175
  entryPointName: 'efc',
171
176
  // outputFile: 'zohodesk-efc-sdk-latest.js',
@@ -221,8 +226,11 @@ let getProdPlugins = (options, publicPath = '') => {
221
226
  hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
222
227
 
223
228
  if (!isDevelopment) {
224
- enableSMap && enableSMapHook && plugins.push(new _plugins.SourceMapHookPlugin());
225
- optimize && plugins.push(new _plugins.OptimizeJSPlugin());
229
+ enableSMap && enableSMapHook && plugins.push(new _plugins.SourceMapHookPlugin()); // optimize && plugins.push(new OptimizeJSPlugin());
230
+ // optimize &&
231
+ // plugins.push(
232
+ // );
233
+
226
234
  plugins.push(new _plugins.ManifestPlugin({
227
235
  fileName: manifestFileName
228
236
  }));
@@ -17,6 +17,8 @@ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nK
17
17
 
18
18
  var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
19
19
 
20
+ var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
21
+
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
24
  // import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
@@ -34,17 +36,19 @@ const {
34
36
  efc: efcOptios
35
37
  } = cliOptions;
36
38
  const {
37
- createSDkFile
39
+ createSDkFile,
40
+ cdnStatement
38
41
  } = efcOptios;
39
42
 
40
43
  class EFCPlugin {
41
44
  constructor(options = {}) {
42
45
  this.isDevelopment = options.isDevelopment;
46
+ this.templateFilePath = options.templateFilePath;
43
47
  this.serverUrl = options.serverUrl;
44
48
  this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
45
49
  // this.i18nManifestFileName = options.i18nManifestFileName;
46
50
  // IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
47
- // So when debugging consider this as well
51
+ // So when debugging consider this as well
48
52
 
49
53
  this.options = Object.assign({}, efcOptios, options);
50
54
  this.options.entryPointName = options.entryPointName || 'efc';
@@ -125,20 +129,35 @@ class EFCPlugin {
125
129
  ${enableRTLSplit ? `const cssDir = ${cssDirStatement};` : ''}
126
130
  const prod = !${this.isDevelopment};
127
131
  let cdnVariableName = "${cdnVariableName}";
128
- let assetURLs = {
129
- //hook
130
- js: ${JSON.stringify(jsPath || serverUrl)},
131
- css: ${JSON.stringify(cssPath || serverUrl)},
132
- i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
133
- };
132
+
133
+ function getAssetUrl(ext) {
134
+ ${cdnStatement ? `
135
+ return (() => {
136
+ let fu = (${cdnStatement});
137
+ return typeof fu === "function" ? fu(ext) : fu;
138
+ })();` : ''}
139
+
140
+ ${publicPaths.callback ? `return (${publicPaths.callback})(ext)` : ''}
141
+
142
+ let assetURLs = {
143
+ //hook
144
+ js: ${JSON.stringify(jsPath || serverUrl)},
145
+ css: ${JSON.stringify(cssPath || serverUrl)},
146
+ i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
147
+ };
148
+
149
+ return assetURLs[ext];
150
+
151
+ }
152
+
134
153
 
135
154
  window.desk_urls={}
136
- window.desk_urls.staticDomain = 'https:' + assetURLs.js + '/';
155
+ window.desk_urls.staticDomain = 'https:' + getAssetUrl('js') + '/';
137
156
  if (prod && cdnVariableName) {
138
- window["${cdnVariableName}"] = 'https:' + assetURLs.css + '/';
157
+ window["${cdnVariableName}"] = 'https:' + getAssetUrl('css') + '/';
139
158
  }
140
159
 
141
- let initalI18nAssets = ${initalI18nAssets}.map(urlpath => "${i18nJsPath}/"+ urlpath);
160
+ let initalI18nAssets = ${initalI18nAssets};
142
161
  let initialAssets = initalI18nAssets.concat(${JSON.stringify(enableRTLSplit ? filteredInitialFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate)) : filteredInitialFiles)});
143
162
 
144
163
  let loadAsset = (id, type, url) => {
@@ -150,12 +169,12 @@ class EFCPlugin {
150
169
  switch(type) {
151
170
  case 'script':
152
171
  case 'i18n':
153
- el.src = (type === 'i18n'? assetURLs.i18n : assetURLs.js)+'/'+url
172
+ el.src = (type === 'i18n'? getAssetUrl('i18n') : getAssetUrl('js'))+'/'+url
154
173
  el.defer = 'defer';
155
174
  document.body.appendChild(el);
156
175
  break;
157
176
  case 'link':
158
- el.href = assetURLs.css+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
177
+ el.href = getAssetUrl('css')+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
159
178
  el.rel = 'stylesheet';
160
179
  document.head.appendChild(el);
161
180
  break;
@@ -186,6 +205,17 @@ class EFCPlugin {
186
205
  apply(compiler) {
187
206
  if (!createSDkFile) {
188
207
  return;
208
+ } //console.log('this.templateFilePath', this.templateFilePath, this.options);
209
+
210
+
211
+ if (this.templateFilePath) {
212
+ new _EFCTemplatePlugin.default({
213
+ templateFilePath: this.templateFilePath,
214
+ publicPath: this.serverUrl,
215
+ i18nFileNameTemplate: this.i18nFileNameTemplate,
216
+ entryPointName: this.options.entryPointName
217
+ }).apply(compiler);
218
+ return;
189
219
  }
190
220
 
191
221
  compiler.hooks.emit.tap('EFCPlugin', compilation => {