kn-cli 1.0.20 → 1.0.22

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.
@@ -10,6 +10,7 @@ module.exports = {
10
10
  // 'home/index': 'src/jsx/home/index.jsx',
11
11
  // },
12
12
  // copyFolder:['static','pluginjs'],//完整复制的文件夹,除了static和pluginjs外其它需要被完整复制的文件夹
13
+ // copyFolder:[{from:'static',to:'folder/static'}],//支持目录自定义配置
13
14
  // hashMode:false,//false=关闭编译后的文件使用hash模式使用原始文件名
14
15
  // cssModule:'global',//css引用默认的模式,global/local/(path)=>global/local
15
16
  // cssModule: (resourcePath) => {
@@ -23,5 +24,9 @@ module.exports = {
23
24
  // cssSplitMode:false,//false=关闭css文件分隔,将css内置到js内
24
25
  // sass:true,//true=开启sass支持,默认仅支持less
25
26
  // indexHtml:false,//false=关闭index.html的注入
27
+ // indexHtml:{
28
+ // template:'index_template.html',
29
+ // output:'../index.html',//将index.html输出到 dist目录外的index.html
30
+ // },
26
31
  // projectSourceFolder:'./',//项目源代码文件夹所在位置,默认是'src'
27
32
  };
@@ -341,21 +341,36 @@ if(indexHtml){
341
341
  if(jsSplitMode===true || jsSplitMode?.runtime !== false){
342
342
  shareJs.splice(0,0,'runtime');
343
343
  }
344
+ let index_template = path.join(dirname, 'index.html');
345
+ let index_template_output= 'index.html';
346
+ if(typeof indexHtml ==='object'){
347
+ if(indexHtml.template){
348
+ index_template = path.join(dirname, indexHtml.template);
349
+ }
350
+ if(indexHtml.output){
351
+ index_template_output = indexHtml.output;
352
+ }
353
+ }
344
354
  plugins.push(
345
355
  new HtmlWebpackPlugin({
346
356
  chunks: ['index',...shareJs],
347
- template: path.join(dirname, 'index.html'),
348
- filename: 'index.html',
357
+ template: index_template,
358
+ filename: index_template_output,
349
359
  inject: true,
350
360
  isProd: process.env.build_env == 'prod',
351
361
  }),
352
362
  )
353
363
  }
354
364
 
355
- const COPY_FOLDER= CLI_CONFIG.copyFolder?['static','pluginjs'].concat(CLI_CONFIG.copyFolder):['static','pluginjs'];
365
+ let COPY_FOLDER= CLI_CONFIG.copyFolder?['static','pluginjs'].concat(CLI_CONFIG.copyFolder):['static','pluginjs'];
366
+ COPY_FOLDER = [...new Set(COPY_FOLDER)];
356
367
  const folderPatterns = COPY_FOLDER.map(folder=>{
357
- return { from: dirname + '/' + folder, to: dirname + '/'+distFolder+'/' + folder ,noErrorOnMissing:true};
358
- })
368
+ if(typeof folder === 'string'){
369
+ return { from: dirname + '/' + folder, to: dirname + '/'+distFolder+'/' + folder ,noErrorOnMissing:true};
370
+ }else{
371
+ return { from: dirname + '/' + folder.from, to: dirname + '/'+distFolder+'/' + folder.to ,noErrorOnMissing:true};
372
+ }
373
+ });
359
374
  plugins.push(
360
375
  new CopyPlugin({
361
376
  patterns: folderPatterns||[]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -29,6 +29,7 @@ module.exports = {
29
29
  'home/index': 'src/jsx/home/index.jsx',
30
30
  },
31
31
  copyFolder:['static','pluginjs'],//默认:[],完整复制的文件夹,除了static和pluginjs外其它需要被完整复制的文件夹
32
+ // copyFolder:[{from:'static',to:'folder/static'}],//支持目录自定义配置
32
33
  hashMode:false,//默认:true,false=关闭编译后的文件使用hash模式使用原始文件名
33
34
  cssModule:'global',//默认:local, css引用默认的模式,global/local/(path)=>global/local
34
35
  // cssModule: (resourcePath) => {
@@ -45,6 +46,10 @@ module.exports = {
45
46
  cssSplitMode:false,//默认:true,false=关闭css文件分隔,将css内置到js内
46
47
  sass:true,//默认:false,true=开启sass支持,默认仅支持less
47
48
  indexHtml:false,//默认:true,false=关闭index.html的注入
49
+ // indexHtml:{
50
+ // template:'index_template.html',
51
+ // output:'../index.html',//将index.html输出到 dist目录外的index.html
52
+ // },
48
53
  projectSourceFolder:'./',//默认:'./public',项目源代码文件夹所在位置,默认是'src'
49
54
  site_root_path:'',//默认:'',站点根目录,
50
55
  // dist:'dist',// 默认:'dist',编译后文件输出目录
@@ -56,6 +61,12 @@ module.exports = {
56
61
  ```
57
62
 
58
63
  # 更新日志
64
+ * 1.0.22
65
+ 1. cli.config.js 扩展indexHtml的配置项,详细参考注释
66
+
67
+ * 1.0.21
68
+ 1. cli.config.js内扩展了copyFolder配置项目的功能,现在支持更多配置,详细参考注释
69
+
59
70
  * 1.0.20
60
71
  1. cli.config.js增加配置site_root_path,用于设置站点根目录
61
72