kn-cli 1.0.18 → 1.0.20

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.
@@ -4,6 +4,7 @@ module.exports = {
4
4
  less:{
5
5
  javascriptEnabled:false,//是否开启less js
6
6
  },
7
+ // site_root_path:'/dist/',// 默认:'',站点根目录
7
8
  // 自定义多入口
8
9
  // entry:{
9
10
  // 'home/index': 'src/jsx/home/index.jsx',
@@ -11,7 +11,6 @@ const CopyPlugin = require('copy-webpack-plugin');
11
11
 
12
12
  //////////// CONFIG ENV ///////////////
13
13
  const API_CONFIG = require('./webpack.api.js');
14
- const cliConfig = require('./cli.config.js');
15
14
  let CLI_CONFIG = {};
16
15
  let existsCli= fs.existsSync('./cli.config.js');
17
16
  if(existsCli){
@@ -32,7 +31,7 @@ console.log(`=====================env end=========================`);
32
31
  const devMode = process.env.build_env !== 'prod';
33
32
  const hashMode = CLI_CONFIG?.hashMode ?? process.env.build_env != 'localdebug';
34
33
  const cssSplitMode = CLI_CONFIG?.cssSplitMode??true;
35
- const resource_path_relative='';
34
+ const resource_path_relative= CLI_CONFIG?.site_root_path??'';
36
35
  const support_sass=CLI_CONFIG?.sass??false;
37
36
  const css_modules= CLI_CONFIG?.cssModule??'local';
38
37
  const jsSplitMode = CLI_CONFIG?.jsSplitMode??true;
@@ -51,6 +50,7 @@ if(CLI_CONFIG?.dist){
51
50
  }
52
51
  }
53
52
 
53
+
54
54
  //////////// CONFIG ENV-END ///////////////
55
55
 
56
56
 
@@ -269,14 +269,16 @@ const optimization= {
269
269
 
270
270
  };
271
271
  if(jsSplitMode){
272
- optimization.runtimeChunk= {
273
- name: 'runtime', // 所有入口有自己的runtime.js
274
- };
272
+ if(jsSplitMode===true||jsSplitMode?.runtime!==false){
273
+ optimization.runtimeChunk= {
274
+ name: 'runtime', // 所有入口有自己的runtime.js
275
+ };
276
+ }
275
277
  optimization.splitChunks= {
276
278
  cacheGroups: {
277
279
  react: {
278
280
  test: /(react)/,
279
- priority: 20,
281
+ priority: 100,
280
282
  name: 'react-bundle',
281
283
  chunks: 'all',
282
284
  enforce: true,
@@ -290,15 +292,15 @@ if(jsSplitMode){
290
292
  },
291
293
  modules: {
292
294
  test: /(node_modules)/,
293
- priority: 2,
295
+ priority: 90,
294
296
  name: 'modules-bundle',
295
297
  chunks: 'all',
296
298
  enforce: true,
297
299
  },
298
300
  default: {
299
301
  name: 'default-bundle',
300
- minChunks: 2,
301
- priority: 50,
302
+ minChunks: 3,
303
+ priority: 10,
302
304
  chunks: 'all',
303
305
  enforce: true,
304
306
  },
@@ -335,7 +337,10 @@ const plugins= [
335
337
 
336
338
  const indexHtml = CLI_CONFIG?.indexHtml ?? true;
337
339
  if(indexHtml){
338
- const shareJs = jsSplitMode?['runtime', 'react-bundle', 'modules-bundle', 'default-bundle', 'styles-bundle']:[];
340
+ const shareJs = jsSplitMode?['react-bundle', 'modules-bundle', 'default-bundle', 'styles-bundle']:[];
341
+ if(jsSplitMode===true || jsSplitMode?.runtime !== false){
342
+ shareJs.splice(0,0,'runtime');
343
+ }
339
344
  plugins.push(
340
345
  new HtmlWebpackPlugin({
341
346
  chunks: ['index',...shareJs],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -39,14 +39,28 @@ module.exports = {
39
39
  // return "local";
40
40
  // },
41
41
  jsSplitMode:false,//默认:true,false=关闭js的模块切割
42
+ // jsSplitMode:{
43
+ // runtime:false,//不单独生成runtime
44
+ // }
42
45
  cssSplitMode:false,//默认:true,false=关闭css文件分隔,将css内置到js内
43
46
  sass:true,//默认:false,true=开启sass支持,默认仅支持less
44
47
  indexHtml:false,//默认:true,false=关闭index.html的注入
45
48
  projectSourceFolder:'./',//默认:'./public',项目源代码文件夹所在位置,默认是'src'
49
+ site_root_path:'',//默认:'',站点根目录,
50
+ // dist:'dist',// 默认:'dist',编译后文件输出目录
51
+ // dist:{// 可详细配置相应资源的输出目录
52
+ // base:'',
53
+ // js:'',//js输出的目录
54
+ // }
46
55
  };
47
56
  ```
48
57
 
49
58
  # 更新日志
59
+ * 1.0.20
60
+ 1. cli.config.js增加配置site_root_path,用于设置站点根目录
61
+
62
+ * 1.0.19
63
+ 1. 对splitChunks内runtime的cli配置支持
50
64
 
51
65
  * 1.0.18
52
66
  1. cli.config.js增加配置项,具体可以参考cli.config.js内的注释