@zohodesk/react-cli 0.0.1-beta.158 → 0.0.1-beta.161.1

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/README.md CHANGED
@@ -1,35 +1,101 @@
1
1
  # React CLI
2
2
 
3
3
  A CLI tool for build modern web application and libraries
4
+
5
+ # 0.0.1-beta.161.1
6
+
7
+ - **Features :-**
8
+ - feature added for pre process logic
9
+ - tailer made requirement for preprocess, just write node js file
10
+ - mention file in `"react-cli" => "preprocess" => "runner"`
11
+ - option parse logic added for react-cli (exprimental)
12
+
13
+ # 0.0.1-beta.161
14
+
15
+ - **Features :-**
16
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
17
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
18
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
19
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
20
+ - `assetsType` are `js`, `css`, `i18n`
21
+ - `lang` this argument only works when `i18n` is `assetsType`
22
+ - feature added for efc `cdnStatement`
23
+ - **Issue fixes:-**
24
+ - css classname hash change issue fix
25
+ - debug package conflit issue fix in nock in (react-cli test)
26
+ - manifest.json css file name correction issue for rtl and ltr
27
+
28
+ # 0.0.1-exp.161.2
29
+
30
+ - Features
31
+ - feature added for efc `templateFilePath` in `package.json` option palce is `"react-cli" => "efc" `
32
+ - `(('publicPath'))` this placeholder will be replace as publicPath string `publicPath`
33
+ - `(('getInitalAssets'))` this placeholder will be replace as function `getInitalAssets`
34
+ - `getInitalAssets` this function has two arguments `assetsType`, `lang`
35
+ - `assetsType` are `js`, `css`, `i18n`
36
+ - `lang` this argument only works when `i18n` is `assetsType`
37
+
38
+ # 0.0.1-exp.161.1
39
+
40
+ - Features
41
+ - feature added for efc `cdnStatement`
42
+ - Issue fixes:-
43
+ - css classname hash change issue fix
44
+ - debug package conflit issue fix in nock in (react-cli test)
45
+ - manifest.json css file name correction issue for rtl and ltr
46
+
47
+ # 0.0.1-beta.160
48
+
49
+ - @zohodesk/normalizer package version updated to 1.0.2
50
+
51
+ # 0.0.1-beta.159
52
+
53
+ - @zohodesk/datetimejs package updated to beta.7
54
+
55
+ # 0.0.1-exp.159
56
+
57
+ - isse fix:-
58
+ - when rtl ltr css split enable manifest json css filename keys comes with hash .
59
+
4
60
  # 0.0.1-beta.158
5
- - Removing source map files from service worker caching.
61
+
62
+ - Removing source map files from service worker caching.
63
+
6
64
  # 0.0.1-beta.157
7
- - Experimental version issue fix(Dummy version removed)
65
+
66
+ - Experimental version issue fix(Dummy version removed)
67
+
8
68
  # 0.0.1-beta.156
9
- - ReportPublish issue fix
69
+
70
+ - ReportPublish issue fix
10
71
 
11
72
  # 0.0.1-beta.155
12
- - get impacted library source files option added
73
+
74
+ - get impacted library source files option added
13
75
 
14
76
  # 0.0.1-beta.154
15
- - mockPrefix option for mock url prefix change
16
- - Issue fix:-
17
- - un wanted {{--js-smap}} in inital html without enable smap in build
77
+
78
+ - mockPrefix option for mock url prefix change
79
+ - Issue fix:-
80
+ - un wanted {{--js-smap}} in inital html without enable smap in build
18
81
 
19
82
  # 0.0.1-beta.153
83
+
20
84
  - Vendor include array added
21
85
  - If you need to include any thrid party js in vendor we can use this array
22
86
 
23
87
  # 0.0.1-beta.152
88
+
24
89
  impact servise related changes:-
90
+
25
91
  - 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)
26
92
  - cssselector_zip option added. will be used like `--cssselector-zip=selectormapping.zip`
27
93
  only work in two ways
28
94
  1. `react-cli start --disable-watch --cssselector-zip=selectormapping.zip` app start command with `--disable-watch` flag and your usaul options
29
95
  2. `react-cli nowatchstart --cssselector-zip=selectormapping.zip` app start command's usaul options
30
96
  #### Urls are:-
31
- Below express path are added, For download zip files and
32
- - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
97
+ Below express path are added, For download zip files and
98
+ - `/zips/${zipname}.zip` for css selector maps zip file (contains css_map filies and original css files)
33
99
  - `/zips/build.zip` build zip file (contains bundled all files)
34
100
 
35
101
  # 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,51 @@ 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
+ console.log(
49
+ 'options.app.preprocessor',
50
+ options.preprocessor.runner,
51
+ preprocesserPath
52
+ );
53
+
54
+ // eslint-disable-next-line default-case
55
+ switch (option) {
56
+ case 'start':
57
+ case 'docs':
58
+ spawn(nodemon, [preprocesserPath], {
59
+ stdio: 'inherit',
60
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
61
+ });
62
+ // NOTE: it's ok if we not close this here
63
+ // Because when node server stops this program willbe closed So this nodemon will be killed as well
64
+ break;
65
+ case 'nowatchstart':
66
+ case 'build:library:es':
67
+ case 'build:component:es':
68
+ case 'build:library:cmjs':
69
+ case 'build:component:cmjs':
70
+ spawnSync('node', [preprocesserPath], {
71
+ stdio: 'inherit',
72
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
73
+ });
74
+ break;
75
+ }
76
+
45
77
  let result;
46
78
  switch (option) {
79
+ case 'preprocessor':
80
+ if (preprocesserPath) {
81
+ result = spawnSync(nodemon, [preprocesserPath], {
82
+ stdio: 'inherit',
83
+ cwd: preprocesserPath.slice(0, preprocesserPath.lastIndexOf('/') + 1)
84
+ });
85
+ process.exit(result.status);
86
+ } else {
87
+ console.error('preProcessor not exists ');
88
+ }
89
+ break;
47
90
  case 'lint-setup': {
48
91
  result = spawnSync(
49
92
  'node',
package/c.sh ADDED
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+
3
+
4
+ # s_time= `echo 1640321666`
5
+ # e_time= 1640121666
6
+ # r_time= s_time - e_time
7
+ # echo `((r_time/60000)) min`
8
+ # s_time= e_time
9
+ # e_time= 1639384489
10
+ # r_time= s_time - e_time
11
+ # echo `((r_time/60000)) min`
12
+
13
+
14
+ main() {
15
+
16
+ s_time=`date +%s`
17
+ npm run build --app_mode=build
18
+ # sleep 2
19
+ # e_time=`date +%s`
20
+ # r_time=$(($s_time - $e_time))
21
+ # echo $s_time
22
+ # echo $e_time
23
+ # echo "$(($r_time/60)) min $(($r_time%60)) sec"
24
+
25
+ printTime() {
26
+ e_time=`date +%s`
27
+ r_time=$(($e_time-$s_time))
28
+ echo "$r_time $s_time $e_time"
29
+ echo "$1 Time: $(($r_time/60)) min $(($r_time%60)) sec"
30
+ s_time=$e_time
31
+ }
32
+ printTime "React-Cli installation"
33
+ sleep 3
34
+ printTime "React-Cli installation1"
35
+ sleep 1
36
+ printTime "React-Cli installation2"
37
+ echo finished
38
+ # echo `(($r_time/60)) min`
39
+ # s_time= e_time
40
+ # e_time= 1639384489
41
+ # r_time= s_time - e_time
42
+ # echo `((r_time/60000)) min
43
+
44
+ }
45
+ main 773
46
+ echo "function call finished"
@@ -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>
@@ -3,12 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "splitChunks", {
7
- enumerable: true,
8
- get: function () {
9
- return _splitChunks.default;
10
- }
11
- });
12
6
  Object.defineProperty(exports, "getEntries", {
13
7
  enumerable: true,
14
8
  get: function () {
@@ -21,6 +15,12 @@ Object.defineProperty(exports, "getPublicPathConfig", {
21
15
  return _getPublicPathConfig.default;
22
16
  }
23
17
  });
18
+ Object.defineProperty(exports, "splitChunks", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _splitChunks.default;
22
+ }
23
+ });
24
24
  Object.defineProperty(exports, "templateParameters", {
25
25
  enumerable: true,
26
26
  get: function () {
@@ -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}(.*)$`] = `${moduleNameMapper[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,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)();
@@ -194,25 +196,7 @@ module.exports = {
194
196
  },
195
197
  resolve: {
196
198
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules'],
197
- alias: disableES5Transpile ? {
198
- '@zohodesk/components/lib': '@zohodesk/components/es',
199
- // '@zohodesk/zc-custom/lib': '@zohodesk/zc-custom/es',
200
- '@zohodesk/dot/lib': '@zohodesk/dot/es',
201
- '@zohodesk/i18n/lib': '@zohodesk/i18n/es',
202
- '@zohodesk/icons/lib': '@zohodesk/icons/es',
203
- '@zohodesk/normalizer/lib': '@zohodesk/normalizer/es',
204
- '@zohodesk/perf-components/lib': '@zohodesk/perf-components/es',
205
- '@zohodesk/perf-middleware/lib': '@zohodesk/perf-middleware/es',
206
- '@zohodesk/permissions/lib': '@zohodesk/permissions/es',
207
- '@zohodesk/platform-middleware/lib': '@zohodesk/platform-middleware/es',
208
- '@zohodesk/react-dnd/lib': '@zohodesk/react-dnd/es',
209
- '@zohodesk/router-middleware/lib': '@zohodesk/router-middleware/es',
210
- '@zohodesk/storage/lib': '@zohodesk/storage/es',
211
- '@zohodesk/svg/lib': '@zohodesk/svg/es',
212
- '@zohodesk/timetracker/lib': '@zohodesk/timetracker/es',
213
- '@zohodesk/variables/lib': '@zohodesk/variables/es',
214
- '@zohodesk/virtualizer/lib': '@zohodesk/virtualizer/es'
215
- } : {}
199
+ alias: disableES5Transpile ? _libAlias.libAlias : {}
216
200
  },
217
201
  resolveLoader: {
218
202
  modules: [_path.default.resolve(__dirname, '..', '..', 'node_modules'), 'node_modules']
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- Object.defineProperty(exports, "getDevJsLoaders", {
6
+ Object.defineProperty(exports, "getCSSLoaders", {
7
7
  enumerable: true,
8
8
  get: function () {
9
- return _getDevJsLoaders.default;
9
+ return _getCSSLoaders.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "getCSSLoaders", {
12
+ Object.defineProperty(exports, "getDevJsLoaders", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _getCSSLoaders.default;
15
+ return _getDevJsLoaders.default;
16
16
  }
17
17
  });
18
18
 
@@ -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',
@@ -72,6 +72,7 @@ let getProdPlugins = (options, publicPath = '') => {
72
72
  const {
73
73
  hasEFC: newOptionForEnableEFC,
74
74
  nameScope: efcNameSpace,
75
+ templateFilePath,
75
76
  localeAttr: efcLocaleAttr
76
77
  } = options.efc;
77
78
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
@@ -166,6 +167,7 @@ let getProdPlugins = (options, publicPath = '') => {
166
167
  isDevelopment,
167
168
  serverUrl: publicPath,
168
169
  i18nFileNameTemplate,
170
+ templateFilePath,
169
171
  i18nManifestFileName,
170
172
  entryPointName: 'efc',
171
173
  // outputFile: 'zohodesk-efc-sdk-latest.js',
@@ -9,34 +9,28 @@ Object.defineProperty(exports, "getDevPlugins", {
9
9
  return _getDevPlugins.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "getProdPlugins", {
13
- enumerable: true,
14
- get: function () {
15
- return _getProdPlugins.default;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "getDocsPlugins", {
19
13
  enumerable: true,
20
14
  get: function () {
21
15
  return _getDocsPlugins.default;
22
16
  }
23
17
  });
24
- Object.defineProperty(exports, "getServerPlugins", {
18
+ Object.defineProperty(exports, "getLibraryPlugins", {
25
19
  enumerable: true,
26
20
  get: function () {
27
- return _getServerPlugins.default;
21
+ return _getLibraryPlugins.default;
28
22
  }
29
23
  });
30
- Object.defineProperty(exports, "getLibraryPlugins", {
24
+ Object.defineProperty(exports, "getProdPlugins", {
31
25
  enumerable: true,
32
26
  get: function () {
33
- return _getLibraryPlugins.default;
27
+ return _getProdPlugins.default;
34
28
  }
35
29
  });
36
- Object.defineProperty(exports, "getUMDComponentPlugins", {
30
+ Object.defineProperty(exports, "getServerPlugins", {
37
31
  enumerable: true,
38
32
  get: function () {
39
- return _getUMDComponentPlugins.default;
33
+ return _getServerPlugins.default;
40
34
  }
41
35
  });
42
36
  Object.defineProperty(exports, "getUMDCSSPlugins", {
@@ -45,6 +39,12 @@ Object.defineProperty(exports, "getUMDCSSPlugins", {
45
39
  return _getUMDCSSPlugins.default;
46
40
  }
47
41
  });
42
+ Object.defineProperty(exports, "getUMDComponentPlugins", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _getUMDComponentPlugins.default;
46
+ }
47
+ });
48
48
 
49
49
  var _getDevPlugins = _interopRequireDefault(require("./getDevPlugins"));
50
50
 
@@ -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 => {