akfun 3.1.2 → 3.1.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akfun",
3
- "version": "3.1.2",
3
+ "version": "3.1.7",
4
4
  "description": "前端脚手架:支持Vue技术栈和react技术栈",
5
5
  "keywords": [
6
6
  "前端工程",
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
- if (autoOpenBrowser) {
120
- spinner.succeed(`${consoleTag}调试模式已开启!`);
121
- // 打印当前环境中的首个html和css地址
122
- const projPath = `${uri}${webpackConfig.output.publicPath}`;
123
- let entryConfig = webpackConfig.entry || {}; // 获取构建入口配置
124
- const entryFiles = (entryConfig && Object.keys(entryConfig)) || [];
125
- if (entryFiles.length > 0) {
126
- // 获取第一个入口文件
127
- const filename = entryFiles[0];
128
- console.info(
129
- `当前运行脚本:\n ${projPath}${filename}.js\n当前运行样式[可能不存在]:\n${projPath}${filename}.css`
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
- curProjectDir.push(resolveToCurrentRoot(dir));
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
- curProjectDir.push(resolveToCurrentRoot(_projectDir));
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 (resourcePath.includes('node_modules')) {
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', // 本地开发环境中的取值
@@ -52,11 +54,13 @@ module.exports = (akfunConfig) => {
52
54
  ]
53
55
  });
54
56
 
55
- // 使用用户自定义的多入口配置,生产对应的多页面多模板(优先使用用户的自定义页面模板)
56
- const htmlWebpackPluginList = entrys2htmlWebpackPlugin(webpackDevConfig.entry, curHtmlTemplate);
57
- htmlWebpackPluginList.forEach((htmlWebpackPlugin) => {
58
- webpackDevConfig.plugins.push(htmlWebpackPlugin);
59
- });
57
+ if (!webpackDevConfig.closeHtmlWebpackPlugin) {
58
+ // 使用用户自定义的多入口配置,生产对应的多页面多模板(优先使用用户的自定义页面模板)
59
+ const htmlWebpackPluginList = entrys2htmlWebpackPlugin(webpackDevConfig.entry, curHtmlTemplate);
60
+ htmlWebpackPluginList.forEach((htmlWebpackPlugin) => {
61
+ webpackDevConfig.plugins.push(htmlWebpackPlugin);
62
+ });
63
+ }
60
64
 
61
65
  // 开启热更新能力
62
66
  const devClientPath = path.resolve(__dirname, '../dev-client'); // 从akfun中获取
@@ -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, // 线上生成环境
@@ -47,7 +47,8 @@ module.exports = (akfunConfig) => {
47
47
  rules: utils.styleLoaders({
48
48
  sourceMap: curEnvConfig.productionSourceMap,
49
49
  environment: 'prod',
50
- cssLoaderUrl: config.webpack.cssLoaderUrl
50
+ cssLoaderUrl: config.webpack.cssLoaderUrl,
51
+ cssLoaderUrlDir: config.webpack.cssLoaderUrlDir
51
52
  })
52
53
  },
53
54
  devtool: curEnvConfig.productionSourceMap ? curEnvConfig.devtool || 'source-map' : false, // 线上生成环境