akfun 2.0.2 → 2.0.7
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
CHANGED
package/src/dev-server.js
CHANGED
|
@@ -11,7 +11,7 @@ const projectConfig = require('./config/index');
|
|
|
11
11
|
const defaultConfig = require('./config/default.config');
|
|
12
12
|
const getDevWebpackConfig = require('./webpack/webpack.dev.conf');
|
|
13
13
|
const deepMergeConfig = require('./utils/deepMergeConfig');
|
|
14
|
-
const {curConsoleTag } = require(
|
|
14
|
+
const { curConsoleTag } = require('./utils/akfunParams');
|
|
15
15
|
|
|
16
16
|
// 构建脚本:一般用于构建开发环境的代码(包含热更新、接口代理等功能)
|
|
17
17
|
module.exports = function (akfunConfig, _consoleTag) {
|
|
@@ -112,11 +112,23 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
112
112
|
}
|
|
113
113
|
process.env.PORT = port;
|
|
114
114
|
const uri = `http://${config.dev.hostname}:${port}`;
|
|
115
|
+
|
|
115
116
|
console.log(`> Listening at ${uri}\n`);
|
|
116
117
|
// 如果是开发环境,自动打开浏览器并跳到项目首页
|
|
117
|
-
if (autoOpenBrowser
|
|
118
|
+
if (autoOpenBrowser) {
|
|
118
119
|
spinner.succeed(`${consoleTag}调试模式已开启!`);
|
|
119
|
-
|
|
120
|
+
// 打印当前环境中的首个html和css地址
|
|
121
|
+
const projPath = `${uri}${webpackConfig.output.publicPath}`;
|
|
122
|
+
let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
|
|
123
|
+
const entryFiles = (entryConfig && Object.keys(entryConfig)) || [];
|
|
124
|
+
if (entryFiles.length > 0) {
|
|
125
|
+
// 获取第一个入口文件
|
|
126
|
+
const filename = entryFiles[0];
|
|
127
|
+
console.info(
|
|
128
|
+
`当前运行脚本:\n ${projPath}${filename}.js\n当前运行样式[可能不存在]:\n${projPath}${filename}.css`
|
|
129
|
+
);
|
|
130
|
+
opn(`${projPath}${filename}.html`);
|
|
131
|
+
}
|
|
120
132
|
}
|
|
121
133
|
server = app.listen(port);
|
|
122
134
|
_resolve();
|
|
@@ -38,6 +38,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
38
38
|
// 获取当前项目目录
|
|
39
39
|
const curProjectDir = getProjectDir(curWebpackConfig.projectDir);
|
|
40
40
|
const webpackConfig = {
|
|
41
|
+
stats: {
|
|
42
|
+
// cachedModules: false,
|
|
43
|
+
// providedExports: true,
|
|
44
|
+
// warnings: false
|
|
45
|
+
},
|
|
41
46
|
entry: curWebpackConfig.entry,
|
|
42
47
|
// target: 'web', // <=== 默认为 'web',可省略
|
|
43
48
|
target: ['web', 'es5'], // 使用共同的特性子集
|
|
@@ -6,6 +6,8 @@ const utils = require('./loaderUtils');
|
|
|
6
6
|
const projectConfig = require('../config/index');
|
|
7
7
|
const getBaseWebpackConfig = require('./webpack.base.conf');
|
|
8
8
|
const entrys2htmlWebpackPlugin = require('../utils/entrys2htmlWebpackPlugin');
|
|
9
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
10
|
+
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
9
11
|
|
|
10
12
|
module.exports = (akfunConfig) => {
|
|
11
13
|
let config = akfunConfig || projectConfig; // 默认使用执行命令目录下的配置数据
|
|
@@ -27,36 +29,29 @@ module.exports = (akfunConfig) => {
|
|
|
27
29
|
module: {
|
|
28
30
|
rules: utils.styleLoaders({
|
|
29
31
|
sourceMap: curEnvConfig.cssSourceMap,
|
|
30
|
-
environment: 'dev'
|
|
32
|
+
environment: 'prod' // 'dev': 不会将css单独提取出来
|
|
31
33
|
})
|
|
32
34
|
},
|
|
33
35
|
// devtool: '#cheap-module-eval-source-map', // 本地开发环境中的取值
|
|
34
36
|
devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'eval-source-map' : 'eval', // 开发环境
|
|
35
37
|
optimization: {
|
|
36
38
|
chunkIds: 'named', // named 对调试更友好的可读的 id。
|
|
37
|
-
emitOnErrors: true
|
|
38
|
-
splitChunks: {
|
|
39
|
-
cacheGroups: {
|
|
40
|
-
defaultVendors: {
|
|
41
|
-
// 4.0: vendors
|
|
42
|
-
test: /node_modules\/(.*)/,
|
|
43
|
-
name: 'vendor',
|
|
44
|
-
chunks: 'initial',
|
|
45
|
-
reuseExistingChunk: true
|
|
46
|
-
},
|
|
47
|
-
common: {
|
|
48
|
-
name: 'common',
|
|
49
|
-
minChunks: 2,
|
|
50
|
-
priority: -20,
|
|
51
|
-
chunks: 'initial',
|
|
52
|
-
reuseExistingChunk: true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
39
|
+
emitOnErrors: true
|
|
56
40
|
},
|
|
57
41
|
plugins: [
|
|
58
42
|
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
|
|
59
|
-
new webpack.HotModuleReplacementPlugin()
|
|
43
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
44
|
+
new MiniCssExtractPlugin({
|
|
45
|
+
// filename: utils.assetsPath('index.css'),
|
|
46
|
+
filename: '[name].css',
|
|
47
|
+
chunkFilename: '[name].css',
|
|
48
|
+
ignoreOrder: false
|
|
49
|
+
}),
|
|
50
|
+
new OptimizeCSSPlugin({
|
|
51
|
+
cssProcessorOptions: {
|
|
52
|
+
safe: true
|
|
53
|
+
}
|
|
54
|
+
})
|
|
60
55
|
]
|
|
61
56
|
});
|
|
62
57
|
|
|
@@ -19,7 +19,7 @@ module.exports = (akfunConfig) => {
|
|
|
19
19
|
mode: curEnvConfig.NODE_ENV, // production 模式,会启动UglifyJsPlugin服务
|
|
20
20
|
output: {
|
|
21
21
|
path: curEnvConfig.assetsRoot, // 输出文件的存放在本地的目录
|
|
22
|
-
filename: '
|
|
22
|
+
filename: '[name].umd.js',
|
|
23
23
|
publicPath: '',
|
|
24
24
|
library: {
|
|
25
25
|
type: 'umd', // 定义打包方式Universal Module Definition,同时支持在CommonJS、AMD和全局变量使用
|