kn-cli 1.0.22 → 1.0.24
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/build/build.sh +1 -0
- package/build/cli.config.js +2 -0
- package/build/postcss.config.js +21 -4
- package/build/webpack.config.js +28 -4
- package/build/writeLog.js +10 -0
- package/package.json +1 -1
- package/readme.md +11 -0
- package/src/build.js +9 -7
package/build/build.sh
CHANGED
package/build/cli.config.js
CHANGED
package/build/postcss.config.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const writeLog = require('./writeLog.js')()
|
|
3
|
+
writeLog('读取 postcss.config.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let CLI_CONFIG = {};
|
|
7
|
+
let existsCli= fs.existsSync('./cli.config.js');
|
|
8
|
+
if(existsCli){
|
|
9
|
+
CLI_CONFIG = require('./cli.config.js');
|
|
10
|
+
}
|
|
11
|
+
const pxtorem = CLI_CONFIG?.pxtorem??true;
|
|
12
|
+
const plugins = [
|
|
13
|
+
require('postcss-preset-env'),
|
|
14
|
+
];
|
|
15
|
+
if(pxtorem){
|
|
16
|
+
writeLog('启用pxtorem');
|
|
17
|
+
plugins.push( require("postcss-pxtorem")({rootValue:100,propList:['*']}) )
|
|
18
|
+
}else{
|
|
19
|
+
writeLog('关闭pxtorem');
|
|
20
|
+
}
|
|
1
21
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
require('postcss-preset-env'),
|
|
4
|
-
require("postcss-pxtorem")({rootValue:100,propList:['*']})
|
|
5
|
-
]
|
|
22
|
+
plugins
|
|
6
23
|
}
|
package/build/webpack.config.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
+
const log = require('./writeLog.js')()
|
|
4
|
+
log('==========读取webpack.config.js===========');
|
|
3
5
|
const webpack = require('webpack');
|
|
4
6
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
5
7
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
@@ -204,11 +206,19 @@ const rules= [
|
|
|
204
206
|
}
|
|
205
207
|
},
|
|
206
208
|
},
|
|
207
|
-
|
|
209
|
+
{
|
|
210
|
+
loader:'postcss-loader',
|
|
211
|
+
options:{
|
|
212
|
+
postcssOptions: {
|
|
213
|
+
config: path.resolve(webpackPath, "postcss.config.js"),
|
|
214
|
+
},
|
|
215
|
+
}
|
|
216
|
+
},
|
|
208
217
|
{
|
|
209
218
|
loader: 'less-loader',
|
|
210
219
|
options:{
|
|
211
|
-
javascriptEnabled: CLI_CONFIG?.less?.javascriptEnabled??false
|
|
220
|
+
javascriptEnabled: CLI_CONFIG?.less?.javascriptEnabled??false,
|
|
221
|
+
modifyVars:CLI_CONFIG?.less?.modifyVars??false,
|
|
212
222
|
}
|
|
213
223
|
}
|
|
214
224
|
],
|
|
@@ -220,7 +230,14 @@ const rules= [
|
|
|
220
230
|
loader: cssSplitMode?MiniCssExtractPlugin.loader:'style-loader',
|
|
221
231
|
},
|
|
222
232
|
'css-loader',
|
|
223
|
-
|
|
233
|
+
{
|
|
234
|
+
loader:'postcss-loader',
|
|
235
|
+
options:{
|
|
236
|
+
postcssOptions: {
|
|
237
|
+
config: path.resolve(webpackPath, "postcss.config.js"),
|
|
238
|
+
},
|
|
239
|
+
}
|
|
240
|
+
},
|
|
224
241
|
],
|
|
225
242
|
},
|
|
226
243
|
];
|
|
@@ -242,7 +259,14 @@ if(support_sass){
|
|
|
242
259
|
}
|
|
243
260
|
},
|
|
244
261
|
},
|
|
245
|
-
|
|
262
|
+
{
|
|
263
|
+
loader:'postcss-loader',
|
|
264
|
+
options:{
|
|
265
|
+
postcssOptions: {
|
|
266
|
+
config: path.resolve(webpackPath, "postcss.config.js"),
|
|
267
|
+
},
|
|
268
|
+
}
|
|
269
|
+
},
|
|
246
270
|
{
|
|
247
271
|
loader: 'sass-loader',
|
|
248
272
|
}
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
# cli.config.js - 构建配置文件
|
|
21
21
|
```js
|
|
22
22
|
module.exports = {
|
|
23
|
+
projectName:'项目名称',
|
|
23
24
|
registryType:'npm',//默认:npm npm镜像源,taobao|npm
|
|
24
25
|
less:{
|
|
25
26
|
javascriptEnabled:false,//默认:false, 是否开启less中对js支持
|
|
@@ -57,10 +58,20 @@ module.exports = {
|
|
|
57
58
|
// base:'',
|
|
58
59
|
// js:'',//js输出的目录
|
|
59
60
|
// }
|
|
61
|
+
// pxtorem:false,//默认:true,开启px转rem模式
|
|
60
62
|
};
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
# 更新日志
|
|
66
|
+
* 1.0.24
|
|
67
|
+
1. 删除了无用的console.log
|
|
68
|
+
|
|
69
|
+
* 1.0.23
|
|
70
|
+
1. 修正postcss.config无法正确读取的bug
|
|
71
|
+
2. 增加对pxtorem插件的开关配置
|
|
72
|
+
3. 增加构建日志文件
|
|
73
|
+
4. 增加 cli.config.js内增加name名称配置
|
|
74
|
+
|
|
64
75
|
* 1.0.22
|
|
65
76
|
1. cli.config.js 扩展indexHtml的配置项,详细参考注释
|
|
66
77
|
|
package/src/build.js
CHANGED
|
@@ -26,7 +26,14 @@ const ROOT=path.resolve(__dirname,"../");
|
|
|
26
26
|
module.exports= async (options={})=> {
|
|
27
27
|
const {type='dev'} = options;
|
|
28
28
|
const projectPath = process.cwd();
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
const cliConfigJs = path.resolve(projectPath,'cli.config.js');
|
|
31
|
+
let existsCli= fs.existsSync(cliConfigJs);
|
|
32
|
+
let cliConfig;
|
|
33
|
+
if(existsCli){
|
|
34
|
+
cliConfig= require(cliConfigJs);
|
|
35
|
+
}
|
|
36
|
+
const projectName = cliConfig?.name??path.parse(projectPath).base;
|
|
30
37
|
|
|
31
38
|
// 用户项目文件夹下的public目录
|
|
32
39
|
const sourceDir = path.resolve(projectPath,'public');
|
|
@@ -39,12 +46,7 @@ module.exports= async (options={})=> {
|
|
|
39
46
|
const tempWebpackPackagePath = path.resolve(tempWebpackDir,'package.json');
|
|
40
47
|
const tempWebpackConfigPath = path.resolve(tempWebpackDir,'webpack.config.js');
|
|
41
48
|
const tempStartShell = path.resolve(tempWebpackDir,'start.sh');
|
|
42
|
-
|
|
43
|
-
let existsCli= fs.existsSync(cliConfigJs);
|
|
44
|
-
let cliConfig;
|
|
45
|
-
if(existsCli){
|
|
46
|
-
cliConfig= require(cliConfigJs);
|
|
47
|
-
}
|
|
49
|
+
|
|
48
50
|
|
|
49
51
|
let projectPackage,webpackPackage;
|
|
50
52
|
|