kn-cli 1.0.23 → 1.0.25

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.
@@ -17,7 +17,6 @@ if(pxtorem){
17
17
  plugins.push( require("postcss-pxtorem")({rootValue:100,propList:['*']}) )
18
18
  }else{
19
19
  writeLog('关闭pxtorem');
20
- console.log('关闭pxtorem')
21
20
  }
22
21
  module.exports = {
23
22
  plugins
@@ -10,6 +10,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
10
10
  const TerserPlugin = require('terser-webpack-plugin');
11
11
  const CopyPlugin = require('copy-webpack-plugin');
12
12
 
13
+ const NowDateTime = Date.now();
13
14
 
14
15
  //////////// CONFIG ENV ///////////////
15
16
  const API_CONFIG = require('./webpack.api.js');
@@ -90,6 +91,19 @@ if(CLI_CONFIG?.entry){
90
91
  }
91
92
  ////////////// ENTRY-END ///////////////
92
93
 
94
+ ////////////// OUTPUT ///////////////
95
+ const output= {
96
+ // devtoolModuleFilenameTemplate:'webpack:///dist/[resource-path]',
97
+ filename: `[name]${hashMode ? '-[chunkhash]' : ''}.js`,
98
+ path: path.join(dirname, distFolder,distJsFolder),
99
+ publicPath: resource_path_relative,
100
+ };
101
+ // 当非hash模式时,未防止chunk缓存,所以在资源后面增加参数用于区分
102
+ if(!hashMode){
103
+ output.chunkFilename = '[name].chunk.js?v='+NowDateTime;
104
+ }
105
+
106
+ ////////////// OUTPUT-END ///////////////
93
107
 
94
108
  /////////////// RULES ////////////////
95
109
  const rules= [
@@ -345,7 +359,7 @@ if(jsSplitMode){
345
359
 
346
360
  const plugins= [
347
361
  new webpack.DefinePlugin({
348
- VERSION_HASH: JSON.stringify(`${Date.now()}-${new Date().toLocaleString()}`),
362
+ VERSION_HASH: JSON.stringify(`${NowDateTime}-${new Date().toLocaleString()}`),
349
363
  BUILD_ENV: JSON.stringify(process.env.build_env),
350
364
  MOCK: process.env.mock == 1 ? '1' : false, //JSON.stringify(process.env.mock)
351
365
  ...API_HOST,
@@ -462,13 +476,7 @@ module.exports = {
462
476
  },
463
477
  // 如果哪天不需要兼容ie11了,把这里@babel/polyfill去掉就行了
464
478
  entry: entry,
465
- output: {
466
- // devtoolModuleFilenameTemplate:'webpack:///dist/[resource-path]',
467
- filename: `[name]${hashMode ? '-[chunkhash]' : ''}.js`,
468
- // chunkFilename: 'js/[name]-[hash].chunk.js', // ./js/[name]-[hash].chunk.js
469
- path: path.join(dirname, distFolder,distJsFolder),
470
- publicPath: resource_path_relative,
471
- },
479
+ output: output,
472
480
  resolve: {
473
481
  modules: [
474
482
  path.resolve(dirname,'node_modules'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kn-cli",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/readme.md CHANGED
@@ -63,6 +63,12 @@ module.exports = {
63
63
  ```
64
64
 
65
65
  # 更新日志
66
+ * 1.0.25
67
+ 1. 修复非hashMode编译情况下,对于异步加载的chunk文件,添加了时间戳进行防缓存处理
68
+
69
+ * 1.0.24
70
+ 1. 删除了无用的console.log
71
+
66
72
  * 1.0.23
67
73
  1. 修正postcss.config无法正确读取的bug
68
74
  2. 增加对pxtorem插件的开关配置
@@ -56,6 +56,9 @@ build(){
56
56
 
57
57
  checkKnCli
58
58
  checkResult "检查kn-cli"
59
+ # dev_mode=watch 代表使用 webpack -w模式将文件编译后生成到磁盘上进行监听更新
60
+ # 默认情况下为 webpack-dev-server模式,将资源编译后放入内存监听
61
+ # export dev_mode=watch
59
62
 
60
63
  kn-cli --dev
61
64
  checkResult "kn-cli --dev"