akfun 3.1.3 → 3.1.8
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/package.json +1 -2
- package/src/dev-server.js +7 -6
- package/src/initData/akfun-package.json +0 -1
- package/src/utils/getProjectDir.js +12 -2
- package/src/webpack/loaderUtils.js +4 -1
- package/src/webpack/vue-loader.conf.js +1 -0
- package/src/webpack/webpack.dev.conf.js +3 -1
- package/src/webpack/webpack.library.conf.js +2 -1
- package/src/webpack/webpack.prod.conf.js +2 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akfun",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.8",
|
|
4
4
|
"description": "前端脚手架:支持Vue技术栈和react技术栈",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"前端工程",
|
|
@@ -113,7 +113,6 @@
|
|
|
113
113
|
"inquirer": "^8.2.0",
|
|
114
114
|
"mini-css-extract-plugin": "^2.5.3",
|
|
115
115
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
116
|
-
"monaco-editor-webpack-plugin": "6.0.0",
|
|
117
116
|
"sass": "^1.49.7",
|
|
118
117
|
"open": "^8.4.0",
|
|
119
118
|
"ora": "^4.0.4",
|
package/src/dev-server.js
CHANGED
|
@@ -111,11 +111,12 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
111
111
|
if (err) {
|
|
112
112
|
_reject(err);
|
|
113
113
|
}
|
|
114
|
+
spinner.succeed(`${consoleTag}调试模式已开启!`);
|
|
115
|
+
|
|
114
116
|
process.env.PORT = port;
|
|
115
117
|
const uri = `http://${config.dev.hostname}:${port}`;
|
|
116
|
-
|
|
117
118
|
console.log(`> Listening at ${uri}\n`);
|
|
118
|
-
|
|
119
|
+
|
|
119
120
|
// 打印当前环境中的首个html和css地址
|
|
120
121
|
const projPath = `${uri}${webpackConfig.output.publicPath}`;
|
|
121
122
|
let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
|
|
@@ -126,10 +127,10 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
126
127
|
console.info(
|
|
127
128
|
`当前运行脚本:\n ${projPath}${filename}.js\n当前运行样式[可能不存在]:\n${projPath}${filename}.css`
|
|
128
129
|
);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
// 是否自动打开浏览器并跳转到第一个入口页面
|
|
131
|
+
if (!config.dev.closeHtmlWebpackPlugin && autoOpenBrowser) {
|
|
132
|
+
open(`${projPath}${filename}.html`, { wait: true });
|
|
133
|
+
}
|
|
133
134
|
}
|
|
134
135
|
server = app.listen(port);
|
|
135
136
|
_resolve();
|
|
@@ -7,10 +7,20 @@ module.exports = (_projectDir) => {
|
|
|
7
7
|
curProjectDir.push(resolveToCurrentRoot('./src'));
|
|
8
8
|
} else if (isArray(_projectDir)) {
|
|
9
9
|
_projectDir.forEach((dir) => {
|
|
10
|
-
|
|
10
|
+
if (dir.indexOf('/') === 0) {
|
|
11
|
+
// 判断是否是绝对路径
|
|
12
|
+
curProjectDir.push(dir);
|
|
13
|
+
} else {
|
|
14
|
+
curProjectDir.push(resolveToCurrentRoot(dir));
|
|
15
|
+
}
|
|
11
16
|
});
|
|
12
17
|
} else if (isString(_projectDir)) {
|
|
13
|
-
|
|
18
|
+
if (_projectDir.indexOf('/') === 0) {
|
|
19
|
+
// 判断是否是绝对路径
|
|
20
|
+
curProjectDir.push(_projectDir);
|
|
21
|
+
} else {
|
|
22
|
+
curProjectDir.push(resolveToCurrentRoot(_projectDir));
|
|
23
|
+
}
|
|
14
24
|
}
|
|
15
25
|
return curProjectDir;
|
|
16
26
|
};
|
|
@@ -44,7 +44,10 @@ exports.cssLoaders = function (options) {
|
|
|
44
44
|
return options.cssLoaderUrl;
|
|
45
45
|
}
|
|
46
46
|
// Don't handle `node_modules` urls
|
|
47
|
-
if (
|
|
47
|
+
if (
|
|
48
|
+
resourcePath.includes('node_modules') ||
|
|
49
|
+
(options.cssLoaderUrlDir && resourcePath.includes(options.cssLoaderUrlDir))
|
|
50
|
+
) {
|
|
48
51
|
return true;
|
|
49
52
|
}
|
|
50
53
|
return false;
|
|
@@ -6,6 +6,7 @@ const isProduction = process.NODE_ENV === 'production';
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
loaders: utils.cssLoaders({
|
|
8
8
|
cssLoaderUrl: config.webpack.cssLoaderUrl, // 用于自定义css-loader配置项[url]
|
|
9
|
+
cssLoaderUrlDir: config.webpack.cssLoaderUrlDir, // 用于设置css-loader配置项[url]的生效目录
|
|
9
10
|
sourceMap: isProduction // 生产环境sourceMap是true
|
|
10
11
|
? config.build.productionSourceMap
|
|
11
12
|
: config.dev.cssSourceMap,
|
|
@@ -7,6 +7,7 @@ const projectConfig = require('../config/index');
|
|
|
7
7
|
const getBaseWebpackConfig = require('./webpack.base.conf');
|
|
8
8
|
const entrys2htmlWebpackPlugin = require('../utils/entrys2htmlWebpackPlugin');
|
|
9
9
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
10
|
+
const config = require('../config');
|
|
10
11
|
// const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
11
12
|
|
|
12
13
|
module.exports = (akfunConfig) => {
|
|
@@ -30,7 +31,8 @@ module.exports = (akfunConfig) => {
|
|
|
30
31
|
rules: utils.styleLoaders({
|
|
31
32
|
sourceMap: curEnvConfig.cssSourceMap,
|
|
32
33
|
environment: 'prod', // 'dev': 不会将css单独提取出来
|
|
33
|
-
cssLoaderUrl: config.webpack.cssLoaderUrl
|
|
34
|
+
cssLoaderUrl: config.webpack.cssLoaderUrl,
|
|
35
|
+
cssLoaderUrlDir: config.webpack.cssLoaderUrlDir
|
|
34
36
|
})
|
|
35
37
|
},
|
|
36
38
|
// devtool: '#cheap-module-eval-source-map', // 本地开发环境中的取值
|
|
@@ -32,7 +32,8 @@ module.exports = (akfunConfig) => {
|
|
|
32
32
|
rules: utils.styleLoaders({
|
|
33
33
|
sourceMap: curEnvConfig.productionSourceMap,
|
|
34
34
|
environment: 'prod',
|
|
35
|
-
cssLoaderUrl: config.webpack.cssLoaderUrl
|
|
35
|
+
cssLoaderUrl: config.webpack.cssLoaderUrl,
|
|
36
|
+
cssLoaderUrlDir: config.webpack.cssLoaderUrlDir
|
|
36
37
|
})
|
|
37
38
|
},
|
|
38
39
|
devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'source-map' : false, // 线上生成环境
|
|
@@ -7,7 +7,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 替换extrac
|
|
|
7
7
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
8
8
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
9
9
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
10
|
-
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
|
11
10
|
|
|
12
11
|
const utils = require('./loaderUtils');
|
|
13
12
|
const { resolve } = require('../utils/pathUtils'); // 统一路径解析
|
|
@@ -47,7 +46,8 @@ module.exports = (akfunConfig) => {
|
|
|
47
46
|
rules: utils.styleLoaders({
|
|
48
47
|
sourceMap: curEnvConfig.productionSourceMap,
|
|
49
48
|
environment: 'prod',
|
|
50
|
-
cssLoaderUrl: config.webpack.cssLoaderUrl
|
|
49
|
+
cssLoaderUrl: config.webpack.cssLoaderUrl,
|
|
50
|
+
cssLoaderUrlDir: config.webpack.cssLoaderUrlDir
|
|
51
51
|
})
|
|
52
52
|
},
|
|
53
53
|
devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'source-map' : false, // 线上生成环境
|
|
@@ -132,11 +132,6 @@ module.exports = (akfunConfig) => {
|
|
|
132
132
|
);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
// 是否开启
|
|
136
|
-
if (curEnvConfig.openMonacoWebpackPlugin) {
|
|
137
|
-
webpackProdConfig.plugins.push(new MonacoWebpackPlugin());
|
|
138
|
-
}
|
|
139
|
-
|
|
140
135
|
if (curEnvConfig.bundleAnalyzerReport) {
|
|
141
136
|
webpackProdConfig.plugins.push(new BundleAnalyzerPlugin());
|
|
142
137
|
}
|