akfun 5.1.10 → 5.1.11
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
|
@@ -92,15 +92,17 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
92
92
|
// serve webpack bundle output
|
|
93
93
|
app.use(devMiddleware);
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
if (!curEnvConfig.closeHotReload) {
|
|
96
|
+
// 启动 webpack-hot-middleware,也就是我们常说的 Hot-reload
|
|
97
|
+
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
|
|
98
|
+
log: false,
|
|
99
|
+
heartbeat: 2000
|
|
100
|
+
});
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// enable hot-reload and state-preserving
|
|
103
|
+
// compilation error display
|
|
104
|
+
app.use(hotMiddleware);
|
|
105
|
+
}
|
|
104
106
|
|
|
105
107
|
const afterCreateServerAction = (isHttps, port) => {
|
|
106
108
|
spinner.succeed(`${consoleTag}调试模式已开启!`);
|
|
@@ -29,7 +29,7 @@ const BannerPack = new webpack.BannerPlugin({
|
|
|
29
29
|
/**
|
|
30
30
|
* webpack.base.conf.js
|
|
31
31
|
* 主要用于设置 rules 和 通用插件
|
|
32
|
-
* _curEnvConfig:
|
|
32
|
+
* _curEnvConfig: 执行环境中的配置,用于记录 dev、build、build2lib 等对应的配置内容;
|
|
33
33
|
* _akfunConfig:完整的配置对象
|
|
34
34
|
*/
|
|
35
35
|
module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
@@ -74,15 +74,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
74
74
|
* 当webpack试图去加载模块的时候,它默认是查找以 .js 结尾的文件的
|
|
75
75
|
*/
|
|
76
76
|
resolve: curWebpackConfig.resolve,
|
|
77
|
-
externals:
|
|
78
|
-
? [
|
|
79
|
-
nodeExternals({
|
|
80
|
-
importType: 'commonjs',
|
|
81
|
-
additionalModuleDirs: curWebpackConfig.additionalModuleDirs || [],
|
|
82
|
-
allowlist: curWebpackConfig.allowList ? curWebpackConfig.allowList : []
|
|
83
|
-
})
|
|
84
|
-
].concat(curWebpackConfig.externals)
|
|
85
|
-
: curWebpackConfig.externals,
|
|
77
|
+
externals: {},
|
|
86
78
|
module: {
|
|
87
79
|
rules: [
|
|
88
80
|
{
|
|
@@ -208,28 +200,37 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
208
200
|
new ProgressBarPlugin()
|
|
209
201
|
]
|
|
210
202
|
};
|
|
203
|
+
|
|
204
|
+
let ignoreNodeModules = curWebpackConfig.ignoreNodeModules;
|
|
211
205
|
// 优先使用执行环境中的配置
|
|
212
206
|
if (curEnvConfig.ignoreNodeModules !== undefined) {
|
|
213
|
-
|
|
214
|
-
const externals = curEnvConfig.externals || curWebpackConfig.external || [];
|
|
215
|
-
webpackConfig.externals = curEnvConfig.ignoreNodeModules
|
|
216
|
-
? [
|
|
217
|
-
nodeExternals({
|
|
218
|
-
importType: 'commonjs',
|
|
219
|
-
additionalModuleDirs:
|
|
220
|
-
curEnvConfig.additionalModuleDirs || curWebpackConfig.additionalModuleDirs || [],
|
|
221
|
-
allowlist: allowList || []
|
|
222
|
-
})
|
|
223
|
-
].concat(externals)
|
|
224
|
-
: externals;
|
|
207
|
+
ignoreNodeModules = curEnvConfig.ignoreNodeModules;
|
|
225
208
|
}
|
|
209
|
+
|
|
210
|
+
// allowList 需要开启 ignoreNodeModules 后有效
|
|
211
|
+
const allowList = curEnvConfig.allowList || curWebpackConfig.allowList;
|
|
212
|
+
// 用户手动添加要剔除的依赖
|
|
213
|
+
const externals = curEnvConfig.externals || curWebpackConfig.external || [];
|
|
214
|
+
|
|
215
|
+
// 设置要剔除的依赖
|
|
216
|
+
webpackConfig.externals = ignoreNodeModules
|
|
217
|
+
? [
|
|
218
|
+
nodeExternals({
|
|
219
|
+
importType: 'commonjs',
|
|
220
|
+
additionalModuleDirs:
|
|
221
|
+
curEnvConfig.additionalModuleDirs || curWebpackConfig.additionalModuleDirs || [],
|
|
222
|
+
allowlist: allowList || []
|
|
223
|
+
})
|
|
224
|
+
].concat(externals)
|
|
225
|
+
: externals;
|
|
226
|
+
|
|
226
227
|
// 集成构建入口相关的配置(优先级更高)
|
|
227
228
|
if (curEnvConfig.entry) {
|
|
228
229
|
webpackConfig.entry = curEnvConfig.entry; // 会覆盖config.webpack.entry的配置
|
|
229
230
|
}
|
|
230
231
|
// 多页面多模板支持能力
|
|
231
232
|
let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
|
|
232
|
-
const entryFiles =
|
|
233
|
+
const entryFiles = Object.keys(entryConfig);
|
|
233
234
|
|
|
234
235
|
if (
|
|
235
236
|
!webpackConfig.entry ||
|
|
@@ -81,10 +81,10 @@ module.exports = (akfunConfig) => {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
// 开启热更新能力
|
|
85
|
-
const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取
|
|
86
|
-
// add hot-reload related code to entry chunks
|
|
87
84
|
if (!curEnvConfig.closeHotReload && webpackDevConfig.entry) {
|
|
85
|
+
// 开启热更新能力
|
|
86
|
+
const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取
|
|
87
|
+
// add hot-reload related code to entry chunks
|
|
88
88
|
Object.keys(webpackDevConfig.entry).forEach((name) => {
|
|
89
89
|
webpackDevConfig.entry[name] = [devClientPath].concat(webpackDevConfig.entry[name]);
|
|
90
90
|
});
|