akfun 2.0.3 → 3.0.0
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 +99 -100
- package/src/config/.eslintrc.js +4 -3
- package/src/config/.eslintrc.ts.js +4 -6
- package/src/config/.eslintrc.vue.js +4 -3
- package/src/config/postcss.config.js +14 -12
- package/src/dev-server.js +27 -14
- package/src/initData/config/akfun.config.js +1 -1
- package/src/webpack/loaderUtils.js +2 -1
- package/src/webpack/webpack.base.conf.js +46 -41
- package/src/webpack/webpack.dev.conf.js +13 -4
- package/src/webpack/webpack.library.conf.js +5 -9
- package/src/webpack/webpack.prod.conf.js +5 -9
- package/src/initData/config/.gitignore +0 -47
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "akfun",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "前端脚手架:支持Vue技术栈和react技术栈",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"前端工程",
|
|
@@ -44,124 +44,123 @@
|
|
|
44
44
|
"url": "https://github.com/wibetter/akfun/issues"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"eslint": "^
|
|
47
|
+
"eslint": "^8.8.0",
|
|
48
|
+
"chalk": "^4.0.0",
|
|
49
|
+
"ora": "^4.0.4"
|
|
48
50
|
},
|
|
49
51
|
"dependencies": {
|
|
50
|
-
"@babel/cli": "^7.
|
|
51
|
-
"@babel/core": "^7.
|
|
52
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
53
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
54
|
-
"@babel/plugin-proposal-export-namespace-from": "^7.
|
|
55
|
-
"@babel/plugin-proposal-function-sent": "^7.
|
|
56
|
-
"@babel/plugin-proposal-json-strings": "^7.
|
|
57
|
-
"@babel/plugin-proposal-numeric-separator": "^7.
|
|
58
|
-
"@babel/plugin-proposal-throw-expressions": "^7.
|
|
52
|
+
"@babel/cli": "^7.17.0",
|
|
53
|
+
"@babel/core": "^7.17.0",
|
|
54
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
55
|
+
"@babel/plugin-proposal-decorators": "^7.17.0",
|
|
56
|
+
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
|
|
57
|
+
"@babel/plugin-proposal-function-sent": "^7.16.7",
|
|
58
|
+
"@babel/plugin-proposal-json-strings": "^7.16.7",
|
|
59
|
+
"@babel/plugin-proposal-numeric-separator": "^7.16.7",
|
|
60
|
+
"@babel/plugin-proposal-throw-expressions": "^7.16.7",
|
|
59
61
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
60
|
-
"@babel/plugin-syntax-import-meta": "^7.10.
|
|
61
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
62
|
+
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
63
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
62
64
|
"@babel/polyfill": "^7.10.1",
|
|
63
|
-
"@babel/preset-env": "^7.
|
|
64
|
-
"@babel/preset-react": "^7.
|
|
65
|
-
"@babel/preset-typescript": "^7.
|
|
66
|
-
"@babel/register": "^7.
|
|
67
|
-
"@mapbox/stylelint-processor-arbitrary-tags": "^0.
|
|
68
|
-
"@rollup/plugin-alias": "^3.1.
|
|
69
|
-
"@rollup/plugin-babel": "^5.
|
|
70
|
-
"@rollup/plugin-commonjs": "^
|
|
71
|
-
"@rollup/plugin-image": "^2.
|
|
65
|
+
"@babel/preset-env": "^7.16.11",
|
|
66
|
+
"@babel/preset-react": "^7.16.7",
|
|
67
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
68
|
+
"@babel/register": "^7.17.0",
|
|
69
|
+
"@mapbox/stylelint-processor-arbitrary-tags": "^0.4.0",
|
|
70
|
+
"@rollup/plugin-alias": "^3.1.9",
|
|
71
|
+
"@rollup/plugin-babel": "^5.3.0",
|
|
72
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
73
|
+
"@rollup/plugin-image": "^2.1.1",
|
|
72
74
|
"@rollup/plugin-json": "^4.1.0",
|
|
73
|
-
"@rollup/plugin-node-resolve": "^
|
|
74
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
75
|
-
"@typescript-eslint/parser": "^
|
|
76
|
-
"@vue/compiler-sfc": "^3.
|
|
77
|
-
"@vue/eslint-config-typescript": "^
|
|
78
|
-
"autoprefixer": "^
|
|
79
|
-
"babel-
|
|
80
|
-
"babel-loader": "^8.
|
|
81
|
-
"babel-plugin-import": "^1.13.
|
|
82
|
-
"cache-loader": "^4.1.0",
|
|
75
|
+
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
76
|
+
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
|
77
|
+
"@typescript-eslint/parser": "^5.10.2",
|
|
78
|
+
"@vue/compiler-sfc": "^3.2.29",
|
|
79
|
+
"@vue/eslint-config-typescript": "^10.0.0",
|
|
80
|
+
"autoprefixer": "^10.4.2",
|
|
81
|
+
"@babel/eslint-parser": "^7.17.0",
|
|
82
|
+
"babel-loader": "^8.2.3",
|
|
83
|
+
"babel-plugin-import": "^1.13.3",
|
|
83
84
|
"chalk": "^4.0.0",
|
|
84
|
-
"compression-webpack-plugin": "^
|
|
85
|
+
"compression-webpack-plugin": "^9.2.0",
|
|
85
86
|
"connect-history-api-fallback": "^1.6.0",
|
|
86
|
-
"copy-webpack-plugin": "^
|
|
87
|
-
"css-loader": "^
|
|
88
|
-
"cssnano": "^
|
|
87
|
+
"copy-webpack-plugin": "^10.2.4",
|
|
88
|
+
"css-loader": "^6.6.0",
|
|
89
|
+
"cssnano": "^5.0.16",
|
|
89
90
|
"deepmerge": "^4.2.2",
|
|
90
|
-
"del": "^
|
|
91
|
+
"del": "^6.0.0",
|
|
91
92
|
"es6-promise-polyfill": "^1.2.0",
|
|
92
|
-
"eslint": "^
|
|
93
|
-
"eslint-config-airbnb-base": "^
|
|
94
|
-
"eslint-config-prettier": "^
|
|
93
|
+
"eslint": "^8.8.0",
|
|
94
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
95
|
+
"eslint-config-prettier": "^8.3.0",
|
|
95
96
|
"eslint-friendly-formatter": "^4.0.1",
|
|
96
|
-
"eslint-import-resolver-webpack": "^0.
|
|
97
|
-
"eslint-
|
|
98
|
-
"eslint-plugin-html": "^6.0
|
|
99
|
-
"eslint-plugin-import": "^2.
|
|
100
|
-
"eslint-plugin-prettier": "^
|
|
101
|
-
"eslint-plugin-react": "^7.
|
|
102
|
-
"eslint-plugin-vue": "^
|
|
97
|
+
"eslint-import-resolver-webpack": "^0.13.2",
|
|
98
|
+
"eslint-webpack-plugin": "^3.1.1",
|
|
99
|
+
"eslint-plugin-html": "^6.2.0",
|
|
100
|
+
"eslint-plugin-import": "^2.25.4",
|
|
101
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
102
|
+
"eslint-plugin-react": "^7.28.0",
|
|
103
|
+
"eslint-plugin-vue": "^8.4.0",
|
|
103
104
|
"eventsource-polyfill": "^0.9.6",
|
|
104
|
-
"express": "^4.17.
|
|
105
|
-
"figlet": "^1.2
|
|
106
|
-
"file-loader": "^6.
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"html-
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"mini-css-extract-plugin": "^0.9.0",
|
|
105
|
+
"express": "^4.17.2",
|
|
106
|
+
"figlet": "^1.5.2",
|
|
107
|
+
"file-loader": "^6.2.0",
|
|
108
|
+
"git-clone": "^0.2.0",
|
|
109
|
+
"glob": "^7.2.0",
|
|
110
|
+
"html-loader": "^3.1.0",
|
|
111
|
+
"html-webpack-plugin": "^5.5.0",
|
|
112
|
+
"http-proxy-middleware": "^2.0.2",
|
|
113
|
+
"inquirer": "^8.2.0",
|
|
114
|
+
"mini-css-extract-plugin": "^2.5.3",
|
|
115
115
|
"monaco-editor-webpack-plugin": "6.0.0",
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"optimize-css-assets-webpack-plugin": "^5.0.3",
|
|
116
|
+
"sass": "^1.49.7",
|
|
117
|
+
"open": "^8.4.0",
|
|
119
118
|
"ora": "^4.0.4",
|
|
120
119
|
"params-replace-loader": "^1.1.6",
|
|
121
|
-
"portfinder": "^1.0.
|
|
122
|
-
"postcss-loader": "^
|
|
123
|
-
"postcss-nested": "^
|
|
124
|
-
"postcss-preset-env": "^
|
|
125
|
-
"postcss-simple-vars": "^
|
|
120
|
+
"portfinder": "^1.0.28",
|
|
121
|
+
"postcss-loader": "^6.2.1",
|
|
122
|
+
"postcss-nested": "^5.0.6",
|
|
123
|
+
"postcss-preset-env": "^7.3.1",
|
|
124
|
+
"postcss-simple-vars": "^6.0.3",
|
|
126
125
|
"progress-bar-webpack-plugin": "^2.1.0",
|
|
127
|
-
"qs": "^6.
|
|
126
|
+
"qs": "^6.10.3",
|
|
128
127
|
"rimraf": "^3.0.2",
|
|
129
|
-
"rollup": "^2.
|
|
130
|
-
"rollup-plugin-postcss": "^
|
|
131
|
-
"rollup-plugin-terser": "^7.0.
|
|
132
|
-
"rollup-plugin-vue": "^6.0.0
|
|
133
|
-
"sass-loader": "^
|
|
134
|
-
"sass-resources-loader": "^2.
|
|
135
|
-
"semver": "^7.3.
|
|
136
|
-
"shelljs": "^0.8.
|
|
137
|
-
"string-replace-loader": "^
|
|
138
|
-
"style-loader": "^
|
|
139
|
-
"stylelint": "^
|
|
140
|
-
"stylelint-config-standard": "^
|
|
141
|
-
"stylelint-webpack-plugin": "^
|
|
142
|
-
"ts-import-plugin": "^
|
|
143
|
-
"ts-loader": "^
|
|
144
|
-
"typescript": "^
|
|
145
|
-
"url-loader": "^4.1.
|
|
146
|
-
"vue-eslint-parser": "^
|
|
147
|
-
"vue-loader": "^15.9.
|
|
148
|
-
"vue-style-loader": "^4.1.
|
|
149
|
-
"vue-template-compiler": "^2.6.
|
|
150
|
-
"webpack": "^5.
|
|
151
|
-
"webpack-bundle-analyzer": "^
|
|
152
|
-
"webpack-cli": "^4.9.
|
|
153
|
-
"webpack-dev-middleware": "^3.
|
|
154
|
-
"webpack-hot-middleware": "^2.25.
|
|
155
|
-
"webpack-merge": "^
|
|
128
|
+
"rollup": "^2.67.0",
|
|
129
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
130
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
131
|
+
"rollup-plugin-vue": "^6.0.0",
|
|
132
|
+
"sass-loader": "^12.4.0",
|
|
133
|
+
"sass-resources-loader": "^2.2.4",
|
|
134
|
+
"semver": "^7.3.5",
|
|
135
|
+
"shelljs": "^0.8.5",
|
|
136
|
+
"string-replace-loader": "^3.1.0",
|
|
137
|
+
"style-loader": "^3.3.1",
|
|
138
|
+
"stylelint": "^14.3.0",
|
|
139
|
+
"stylelint-config-standard": "^24.0.0",
|
|
140
|
+
"stylelint-webpack-plugin": "^3.1.1",
|
|
141
|
+
"ts-import-plugin": "^2.0.0",
|
|
142
|
+
"ts-loader": "^9.2.6",
|
|
143
|
+
"typescript": "^4.5.5",
|
|
144
|
+
"url-loader": "^4.1.1",
|
|
145
|
+
"vue-eslint-parser": "^8.2.0",
|
|
146
|
+
"vue-loader": "^15.9.8",
|
|
147
|
+
"vue-style-loader": "^4.1.3",
|
|
148
|
+
"vue-template-compiler": "^2.6.14",
|
|
149
|
+
"webpack": "^5.68.0",
|
|
150
|
+
"webpack-bundle-analyzer": "^4.5.0",
|
|
151
|
+
"webpack-cli": "^4.9.2",
|
|
152
|
+
"webpack-dev-middleware": "^5.3.1",
|
|
153
|
+
"webpack-hot-middleware": "^2.25.1",
|
|
154
|
+
"webpack-merge": "^5.8.0",
|
|
156
155
|
"webpack-node-externals": "^3.0.0",
|
|
157
|
-
"yargs": "^
|
|
156
|
+
"yargs": "^17.3.1"
|
|
158
157
|
},
|
|
159
158
|
"devDependencies": {
|
|
160
|
-
"@commitlint/cli": "^
|
|
161
|
-
"@commitlint/config-conventional": "^
|
|
162
|
-
"husky": "^4.
|
|
163
|
-
"lint-staged": "^
|
|
164
|
-
"prettier": "^2.
|
|
159
|
+
"@commitlint/cli": "^16.1.0",
|
|
160
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
161
|
+
"husky": "^4.3.8",
|
|
162
|
+
"lint-staged": "^12.3.3",
|
|
163
|
+
"prettier": "^2.5.1"
|
|
165
164
|
},
|
|
166
165
|
"engines": {
|
|
167
166
|
"node": ">= 10.13.0",
|
package/src/config/.eslintrc.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
const getCurWebpackConfig = require('../utils/getCurWebpackConfig
|
|
1
|
+
const getCurWebpackConfig = require('../utils/getCurWebpackConfig'); // 用于获取当前webpack配置的方法
|
|
2
2
|
const curWebpackBaseConfPath = getCurWebpackConfig('base');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
root: true,
|
|
6
|
-
parser: 'babel-
|
|
6
|
+
parser: '@babel/eslint-parser', // 指定eslint解析器的,解析器必须符合规则
|
|
7
7
|
// 此项是用来指定javaScript语言类型和风格,sourceType用来指定js导入的方式,默认是script,此处设置为module,指某块导入方式
|
|
8
8
|
parserOptions: {
|
|
9
|
-
ecmaVersion:
|
|
9
|
+
ecmaVersion: 8,
|
|
10
|
+
requireConfigFile: false,
|
|
10
11
|
sourceType: 'module', // 支持的ES语法版本,默认为5。注意只是语法,不包括ES的全局变量
|
|
11
12
|
ecmaFeatures: {
|
|
12
13
|
// Features是特征的意思,这里用于指定要使用其他那些语言对象
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const getCurWebpackConfig = require('../utils/getCurWebpackConfig
|
|
1
|
+
const getCurWebpackConfig = require('../utils/getCurWebpackConfig'); // 用于获取当前webpack配置的方法
|
|
2
2
|
const curWebpackBaseConfPath = getCurWebpackConfig('base');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
@@ -6,8 +6,9 @@ module.exports = {
|
|
|
6
6
|
parser: '@typescript-eslint/parser',
|
|
7
7
|
// 此项是用来指定javaScript语言类型和风格,sourceType用来指定js导入的方式,默认是script,此处设置为module,指某块导入方式
|
|
8
8
|
parserOptions: {
|
|
9
|
-
parser: 'babel-
|
|
10
|
-
ecmaVersion:
|
|
9
|
+
parser: '@babel/eslint-parser', // babel-eslint解析器是对babel解析器的包装使其与ESLint解析
|
|
10
|
+
ecmaVersion: 8,
|
|
11
|
+
requireConfigFile: false,
|
|
11
12
|
sourceType: 'module', // 支持的ES语法版本,默认为5。注意只是语法,不包括ES的全局变量
|
|
12
13
|
ecmaFeatures: {
|
|
13
14
|
// Features是特征的意思,这里用于指定要使用其他那些语言对象
|
|
@@ -83,8 +84,5 @@ module.exports = {
|
|
|
83
84
|
'object-curly-newline': 0, // 该规则在对象文字括号或销毁分配中强制使用一致的换行符
|
|
84
85
|
'operator-linebreak': [0, 'before'], // 换行时运算符在行尾还是行首
|
|
85
86
|
'max-len': ['warn', { code: 150 }]
|
|
86
|
-
},
|
|
87
|
-
linterOptions: {
|
|
88
|
-
exclude: ['node_modules']
|
|
89
87
|
}
|
|
90
88
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const getCurWebpackConfig = require('../utils/getCurWebpackConfig
|
|
1
|
+
const getCurWebpackConfig = require('../utils/getCurWebpackConfig'); // 用于获取当前webpack配置的方法
|
|
2
2
|
const curWebpackBaseConfPath = getCurWebpackConfig('base');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
@@ -6,8 +6,9 @@ module.exports = {
|
|
|
6
6
|
parser: 'vue-eslint-parser', // 指定eslint解析器的,解析器必须符合规则
|
|
7
7
|
// 此项是用来指定javaScript语言类型和风格,sourceType用来指定js导入的方式,默认是script,此处设置为module,指某块导入方式
|
|
8
8
|
parserOptions: {
|
|
9
|
-
parser: 'babel-
|
|
10
|
-
ecmaVersion:
|
|
9
|
+
parser: '@babel/eslint-parser', // babel-eslint解析器是对babel解析器的包装使其与ESLint解析
|
|
10
|
+
ecmaVersion: 8,
|
|
11
|
+
requireConfigFile: false,
|
|
11
12
|
sourceType: 'module', // 支持的ES语法版本,默认为5。注意只是语法,不包括ES的全局变量
|
|
12
13
|
ecmaFeatures: {
|
|
13
14
|
// Features是特征的意思,这里用于指定要使用其他那些语言对象
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
// https://www.npmjs.com/package/autoprefixer
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
postcssOptions: {
|
|
5
|
+
plugins: [
|
|
6
|
+
require('autoprefixer')({
|
|
7
|
+
overrideBrowserslist: [
|
|
8
|
+
'> 1%',
|
|
9
|
+
'last 2 versions',
|
|
10
|
+
'not ie <= 8',
|
|
11
|
+
'iOS >= 8',
|
|
12
|
+
'Firefox >= 20',
|
|
13
|
+
'Android > 4.4'
|
|
14
|
+
]
|
|
15
|
+
})
|
|
16
|
+
]
|
|
17
|
+
}
|
|
16
18
|
};
|
package/src/dev-server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const open = require('open');
|
|
2
2
|
const ora = require('ora');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const express = require('express');
|
|
@@ -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) {
|
|
@@ -43,16 +43,26 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
43
43
|
|
|
44
44
|
// 使用 express 启动一个服务
|
|
45
45
|
const app = express();
|
|
46
|
+
|
|
46
47
|
// 获取开发环境的webpack基本配置
|
|
47
48
|
const webpackConfig = getDevWebpackConfig(config);
|
|
49
|
+
|
|
50
|
+
// serve pure public assets
|
|
51
|
+
// 拼接 public 文件夹的静态资源路径
|
|
52
|
+
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
|
|
53
|
+
app.use(staticPath, express.static(resolve('public')));
|
|
54
|
+
|
|
48
55
|
const compiler = webpack(webpackConfig); // 启动 webpack 进行编译
|
|
49
56
|
|
|
50
57
|
// 启动 webpack-dev-middleware,将编译后的文件暂存到内存中
|
|
51
58
|
const devMiddleware = require('webpack-dev-middleware')(compiler, {
|
|
52
59
|
publicPath: webpackConfig.output.publicPath,
|
|
53
|
-
|
|
60
|
+
stats: true
|
|
54
61
|
});
|
|
55
62
|
|
|
63
|
+
// serve webpack bundle output
|
|
64
|
+
app.use(devMiddleware);
|
|
65
|
+
|
|
56
66
|
// 启动 webpack-hot-middleware,也就是我们常说的 Hot-reload
|
|
57
67
|
const hotMiddleware = require('webpack-hot-middleware')(compiler, {
|
|
58
68
|
log: false,
|
|
@@ -83,15 +93,6 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
83
93
|
// handle fallback for HTML5 history API
|
|
84
94
|
app.use(require('connect-history-api-fallback')());
|
|
85
95
|
|
|
86
|
-
// serve webpack bundle output
|
|
87
|
-
app.use(devMiddleware);
|
|
88
|
-
|
|
89
|
-
// serve pure public assets
|
|
90
|
-
// 拼接 public 文件夹的静态资源路径
|
|
91
|
-
const staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory);
|
|
92
|
-
|
|
93
|
-
app.use(staticPath, express.static(resolve('public')));
|
|
94
|
-
|
|
95
96
|
let _resolve;
|
|
96
97
|
let _reject;
|
|
97
98
|
const readyPromise = new Promise((resolve, reject) => {
|
|
@@ -112,11 +113,23 @@ module.exports = function (akfunConfig, _consoleTag) {
|
|
|
112
113
|
}
|
|
113
114
|
process.env.PORT = port;
|
|
114
115
|
const uri = `http://${config.dev.hostname}:${port}`;
|
|
116
|
+
|
|
115
117
|
console.log(`> Listening at ${uri}\n`);
|
|
116
118
|
// 如果是开发环境,自动打开浏览器并跳到项目首页
|
|
117
|
-
if (autoOpenBrowser
|
|
119
|
+
if (autoOpenBrowser) {
|
|
118
120
|
spinner.succeed(`${consoleTag}调试模式已开启!`);
|
|
119
|
-
|
|
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
|
+
);
|
|
131
|
+
open(`${projPath}${filename}.html`, { wait: true });
|
|
132
|
+
}
|
|
120
133
|
}
|
|
121
134
|
server = app.listen(port);
|
|
122
135
|
_resolve();
|
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
|
22
22
|
},
|
|
23
23
|
resolve: {
|
|
24
24
|
// webpack的resolve配置
|
|
25
|
-
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', 'json'], // 用于配置webpack在尝试过程中用到的后缀列表
|
|
25
|
+
extensions: ['.js', '.jsx', '.ts', '.tsx', '.vue', '.json'], // 用于配置webpack在尝试过程中用到的后缀列表
|
|
26
26
|
alias: {
|
|
27
27
|
'@': resolve('src'),
|
|
28
28
|
$components: resolve('src/components'),
|
|
@@ -36,6 +36,7 @@ exports.cssLoaders = function (options) {
|
|
|
36
36
|
const cssLoader = {
|
|
37
37
|
loader: 'css-loader',
|
|
38
38
|
options: {
|
|
39
|
+
url: false, // enables/disables url()/image-set() functions handling
|
|
39
40
|
sourceMap: options.sourceMap
|
|
40
41
|
}
|
|
41
42
|
};
|
|
@@ -56,7 +57,7 @@ exports.cssLoaders = function (options) {
|
|
|
56
57
|
{
|
|
57
58
|
loader: MiniCssExtractPlugin.loader,
|
|
58
59
|
options: {
|
|
59
|
-
esModule:
|
|
60
|
+
esModule: false // enable a CommonJS syntax using
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
cssLoader,
|
|
@@ -5,8 +5,9 @@ const webpack = require('webpack');
|
|
|
5
5
|
const StyleLintPlugin = require('stylelint-webpack-plugin');
|
|
6
6
|
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
|
7
7
|
const nodeExternals = require('webpack-node-externals');
|
|
8
|
-
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
|
8
|
+
// const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
|
9
9
|
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
|
10
|
+
const ESLintPlugin = require('eslint-webpack-plugin');
|
|
10
11
|
const utils = require('./loaderUtils');
|
|
11
12
|
const vueLoaderConfig = require('./vue-loader.conf');
|
|
12
13
|
const { resolve, resolveToCurrentRoot } = require('../utils/pathUtils');
|
|
@@ -38,6 +39,11 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
38
39
|
// 获取当前项目目录
|
|
39
40
|
const curProjectDir = getProjectDir(curWebpackConfig.projectDir);
|
|
40
41
|
const webpackConfig = {
|
|
42
|
+
stats: {
|
|
43
|
+
// cachedModules: false,
|
|
44
|
+
// providedExports: true,
|
|
45
|
+
// warnings: false
|
|
46
|
+
},
|
|
41
47
|
entry: curWebpackConfig.entry,
|
|
42
48
|
// target: 'web', // <=== 默认为 'web',可省略
|
|
43
49
|
target: ['web', 'es5'], // 使用共同的特性子集
|
|
@@ -139,18 +145,22 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
139
145
|
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
|
|
140
146
|
}
|
|
141
147
|
},
|
|
142
|
-
{
|
|
143
|
-
test: /\.(html)$/,
|
|
144
|
-
use: {
|
|
145
|
-
loader: 'html-loader'
|
|
146
|
-
}
|
|
147
|
-
},
|
|
148
148
|
{
|
|
149
149
|
test: /\.(js|ts|tsx|jsx|vue|css|html)$/,
|
|
150
150
|
loader: 'params-replace-loader',
|
|
151
151
|
include: curProjectDir, // [resolve('src')],
|
|
152
152
|
exclude: [/node_modules/, resolve('src/mock/data')], // 排除不需要进行校验的文件夹
|
|
153
153
|
options: config.envParams
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
test: /\.(html)$/,
|
|
157
|
+
use: {
|
|
158
|
+
loader: 'html-loader',
|
|
159
|
+
options: {
|
|
160
|
+
minimize: true,
|
|
161
|
+
sources: false // Enables/Disables sources handling
|
|
162
|
+
}
|
|
163
|
+
}
|
|
154
164
|
}
|
|
155
165
|
]
|
|
156
166
|
},
|
|
@@ -161,7 +171,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
161
171
|
}),
|
|
162
172
|
// 请确保引入这个插件来施展魔法
|
|
163
173
|
new VueLoaderPlugin(),
|
|
164
|
-
new FriendlyErrorsPlugin(),
|
|
174
|
+
// new FriendlyErrorsPlugin(),
|
|
165
175
|
new ProgressBarPlugin()
|
|
166
176
|
]
|
|
167
177
|
};
|
|
@@ -213,47 +223,42 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
213
223
|
// 是否开启ESLint
|
|
214
224
|
if (config.settings.enableESLint) {
|
|
215
225
|
// ts类型
|
|
216
|
-
webpackConfig.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
options: {
|
|
226
|
+
webpackConfig.plugins.push(
|
|
227
|
+
new ESLintPlugin({
|
|
228
|
+
// context: resolve('src'),
|
|
229
|
+
extensions: ['ts', 'tsx'],
|
|
230
|
+
// include: curProjectDir, // [resolve('src')],
|
|
231
|
+
exclude: 'node_modules',
|
|
223
232
|
cache: true,
|
|
224
233
|
fix: config.settings.enableESLintFix || false,
|
|
225
234
|
formatter: require('eslint-friendly-formatter'),
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
235
|
+
overrideConfigFile: path.resolve(__dirname, '../config/.eslintrc.ts.js')
|
|
236
|
+
})
|
|
237
|
+
);
|
|
229
238
|
// 通用js类型
|
|
230
|
-
webpackConfig.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
options: {
|
|
237
|
-
cache: true, // the cache is written to the ./node_modules/.cache/eslint-loader director
|
|
239
|
+
webpackConfig.plugins.push(
|
|
240
|
+
new ESLintPlugin({
|
|
241
|
+
extensions: ['js', 'jsx'],
|
|
242
|
+
// include: curProjectDir, // [resolve('src')],
|
|
243
|
+
exclude: 'node_modules',
|
|
244
|
+
cache: true,
|
|
238
245
|
fix: config.settings.enableESLintFix || false,
|
|
239
246
|
formatter: require('eslint-friendly-formatter'),
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
|
|
247
|
+
overrideConfigFile: path.resolve(__dirname, '../config/.eslintrc.js')
|
|
248
|
+
})
|
|
249
|
+
);
|
|
243
250
|
// vue单文件类型
|
|
244
|
-
webpackConfig.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
exclude: /node_modules/,
|
|
250
|
-
options: {
|
|
251
|
+
webpackConfig.plugins.push(
|
|
252
|
+
new ESLintPlugin({
|
|
253
|
+
extensions: ['vue'],
|
|
254
|
+
// include: curProjectDir, // [resolve('src')],
|
|
255
|
+
exclude: 'node_modules',
|
|
251
256
|
cache: true,
|
|
252
257
|
fix: config.settings.enableESLintFix || false,
|
|
253
258
|
formatter: require('eslint-friendly-formatter'),
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
259
|
+
overrideConfigFile: path.resolve(__dirname, '../config/.eslintrc.vue.js')
|
|
260
|
+
})
|
|
261
|
+
);
|
|
257
262
|
}
|
|
258
263
|
// 是否开启StyleLint: 用于验证scss文件里面的style规范
|
|
259
264
|
if (config.settings.enableStyleLint) {
|
|
@@ -264,7 +269,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
264
269
|
webpackConfig.plugins.push(
|
|
265
270
|
new StyleLintPlugin({
|
|
266
271
|
files: ['src/**/*.vue'],
|
|
267
|
-
quiet: true,
|
|
272
|
+
// quiet: true,
|
|
268
273
|
cache: true,
|
|
269
274
|
cacheLocation: resolveToCurrentRoot('./node_modules/stylelint/.vue-cache'),
|
|
270
275
|
fix: config.settings.enableStyleLintFix,
|
|
@@ -276,7 +281,7 @@ module.exports = (_curEnvConfig, _akfunConfig) => {
|
|
|
276
281
|
webpackConfig.plugins.push(
|
|
277
282
|
new StyleLintPlugin({
|
|
278
283
|
files: 'src/**/*.s?(a|c)ss',
|
|
279
|
-
quiet: true,
|
|
284
|
+
// quiet: true,
|
|
280
285
|
cache: true,
|
|
281
286
|
cacheLocation: resolveToCurrentRoot('./node_modules/stylelint/.cache'),
|
|
282
287
|
fix: config.settings.enableStyleLintFix,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const webpack = require('webpack');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const merge = require('webpack-merge');
|
|
3
|
+
const { merge } = require('webpack-merge');
|
|
4
4
|
const utils = require('./loaderUtils');
|
|
5
5
|
// 引入当前项目配置文件
|
|
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,18 +29,25 @@ 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
|
|
39
|
+
emitOnErrors: true,
|
|
40
|
+
minimize: false
|
|
38
41
|
},
|
|
39
42
|
plugins: [
|
|
40
43
|
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
|
|
41
|
-
new webpack.HotModuleReplacementPlugin()
|
|
44
|
+
new webpack.HotModuleReplacementPlugin(),
|
|
45
|
+
new MiniCssExtractPlugin({
|
|
46
|
+
// filename: utils.assetsPath('index.css'),
|
|
47
|
+
filename: '[name].css',
|
|
48
|
+
chunkFilename: '[name].css',
|
|
49
|
+
ignoreOrder: false
|
|
50
|
+
})
|
|
42
51
|
]
|
|
43
52
|
});
|
|
44
53
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const merge = require('webpack-merge');
|
|
2
|
-
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
1
|
+
const { merge } = require('webpack-merge');
|
|
2
|
+
// const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
3
3
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 替换extract-text-webpack-plugin
|
|
4
4
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
5
5
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
@@ -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和全局变量使用
|
|
@@ -41,7 +41,8 @@ module.exports = (akfunConfig) => {
|
|
|
41
41
|
* deterministic 在不同的编译中不变的短数字 id。有益于长期缓存。在生产模式中会默认开启。
|
|
42
42
|
*/
|
|
43
43
|
chunkIds: 'named',
|
|
44
|
-
emitOnErrors: true
|
|
44
|
+
emitOnErrors: true,
|
|
45
|
+
minimize: true
|
|
45
46
|
},
|
|
46
47
|
plugins: [
|
|
47
48
|
new MiniCssExtractPlugin({
|
|
@@ -49,11 +50,6 @@ module.exports = (akfunConfig) => {
|
|
|
49
50
|
filename: '[name].css',
|
|
50
51
|
chunkFilename: '[name].css',
|
|
51
52
|
ignoreOrder: false
|
|
52
|
-
}),
|
|
53
|
-
new OptimizeCSSPlugin({
|
|
54
|
-
cssProcessorOptions: {
|
|
55
|
-
safe: true
|
|
56
|
-
}
|
|
57
53
|
})
|
|
58
54
|
]
|
|
59
55
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const merge = require('webpack-merge');
|
|
3
|
+
const { merge } = require('webpack-merge');
|
|
4
4
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
5
5
|
// const ExtractTextPlugin = require('extract-text-webpack-plugin'); // 不支持webpack4.0
|
|
6
|
-
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
6
|
+
// const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin');
|
|
7
7
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); // 替换extract-text-webpack-plugin
|
|
8
8
|
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
|
|
9
9
|
const CompressionWebpackPlugin = require('compression-webpack-plugin');
|
|
@@ -70,13 +70,14 @@ module.exports = (akfunConfig) => {
|
|
|
70
70
|
reuseExistingChunk: true
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
|
+
minimize: true
|
|
74
75
|
},
|
|
75
76
|
plugins: [
|
|
76
77
|
new MiniCssExtractPlugin({
|
|
77
78
|
filename: utils.assetsPath('css/[name].[contenthash:8].css'),
|
|
78
79
|
ignoreOrder: false // Enable to remove warnings about conflicting order
|
|
79
|
-
})
|
|
80
|
+
})
|
|
80
81
|
// Compress extracted CSS. We are using this plugin so that possible
|
|
81
82
|
// duplicated CSS from different components can be deduped.
|
|
82
83
|
/**
|
|
@@ -87,11 +88,6 @@ module.exports = (akfunConfig) => {
|
|
|
87
88
|
* cssProcessorOptions:传递给cssProcessor的选项,默认为 {}
|
|
88
89
|
* canPrint:一个布尔值,指示插件是否可以将消息打印到控制台,默认为 true
|
|
89
90
|
*/
|
|
90
|
-
new OptimizeCSSPlugin({
|
|
91
|
-
cssProcessorOptions: {
|
|
92
|
-
safe: true
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
91
|
]
|
|
96
92
|
});
|
|
97
93
|
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Numerous always-ignore extensions
|
|
2
|
-
*.bak
|
|
3
|
-
*.patch
|
|
4
|
-
*.diff
|
|
5
|
-
*.err
|
|
6
|
-
|
|
7
|
-
# temp file for git conflict merging
|
|
8
|
-
*.orig
|
|
9
|
-
*.log
|
|
10
|
-
*.rej
|
|
11
|
-
*.swo
|
|
12
|
-
*.swp
|
|
13
|
-
*.zip
|
|
14
|
-
*.vi
|
|
15
|
-
*~
|
|
16
|
-
*.sass-cache
|
|
17
|
-
*.tmp.html
|
|
18
|
-
*.dump
|
|
19
|
-
|
|
20
|
-
# OS or Editor folders
|
|
21
|
-
.DS_Store
|
|
22
|
-
._*
|
|
23
|
-
.cache
|
|
24
|
-
.project
|
|
25
|
-
.settings
|
|
26
|
-
.tmproj
|
|
27
|
-
*.esproj
|
|
28
|
-
*.sublime-project
|
|
29
|
-
*.sublime-workspace
|
|
30
|
-
nbproject
|
|
31
|
-
thumbs.db
|
|
32
|
-
*.iml
|
|
33
|
-
.vscode/
|
|
34
|
-
|
|
35
|
-
# Folders to ignore
|
|
36
|
-
.hg
|
|
37
|
-
.svn
|
|
38
|
-
.CVS
|
|
39
|
-
.idea
|
|
40
|
-
node_modules/
|
|
41
|
-
jscoverage_lib/
|
|
42
|
-
.svn
|
|
43
|
-
|
|
44
|
-
# log files
|
|
45
|
-
npm-debug.log*
|
|
46
|
-
yarn-debug.log*
|
|
47
|
-
yarn-error.log*
|