akfun 3.1.1 → 3.1.6
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
|
@@ -111,23 +111,24 @@ 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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
+
// 是否自动打开浏览器并跳转到第一个入口页面
|
|
131
|
+
if (!config.dev.closeHtmlWebpackPlugin && autoOpenBrowser) {
|
|
131
132
|
open(`${projPath}${filename}.html`, { wait: true });
|
|
132
133
|
}
|
|
133
134
|
}
|
|
@@ -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
|
};
|
|
@@ -308,7 +308,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
308
308
|
// 判断是否有自定义plugins
|
|
309
309
|
if (curWebpackConfig.plugins && Array.isArray(curWebpackConfig.plugins)) {
|
|
310
310
|
// 添加自定义webpack插件
|
|
311
|
-
webpackConfig.plugins.
|
|
311
|
+
webpackConfig.plugins.push(...curWebpackConfig.plugins);
|
|
312
312
|
}
|
|
313
313
|
|
|
314
314
|
return webpackConfig;
|
|
@@ -52,11 +52,13 @@ module.exports = (akfunConfig) => {
|
|
|
52
52
|
]
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
if (!webpackDevConfig.closeHtmlWebpackPlugin) {
|
|
56
|
+
// 使用用户自定义的多入口配置,生产对应的多页面多模板(优先使用用户的自定义页面模板)
|
|
57
|
+
const htmlWebpackPluginList = entrys2htmlWebpackPlugin(webpackDevConfig.entry, curHtmlTemplate);
|
|
58
|
+
htmlWebpackPluginList.forEach((htmlWebpackPlugin) => {
|
|
59
|
+
webpackDevConfig.plugins.push(htmlWebpackPlugin);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
60
62
|
|
|
61
63
|
// 开启热更新能力
|
|
62
64
|
const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取
|
|
@@ -138,7 +138,7 @@ module.exports = (akfunConfig) => {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
if (curEnvConfig.bundleAnalyzerReport) {
|
|
141
|
-
|
|
141
|
+
webpackProdConfig.plugins.push(new BundleAnalyzerPlugin());
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
return webpackProdConfig;
|