qmzreact 1.0.1 → 1.0.2
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/README.md +4 -3
- package/conf/config/index.js +4 -2
- package/conf/config/loaders.js +27 -6
- package/conf/options.js +7 -2
- package/conf/webpack-server.js +11 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,10 +45,10 @@ yarn add --dev qmzreact
|
|
|
45
45
|
示例配置:
|
|
46
46
|
```js
|
|
47
47
|
module.exports = {
|
|
48
|
-
port:
|
|
48
|
+
port: 8888,
|
|
49
49
|
publicPath: '/',
|
|
50
50
|
// 构建输出目录
|
|
51
|
-
buildDir: '
|
|
51
|
+
buildDir: 'build',
|
|
52
52
|
alias: {
|
|
53
53
|
// 默认配置
|
|
54
54
|
"@": path.resolve(__dirname, 'src')
|
|
@@ -60,12 +60,13 @@ module.exports = {
|
|
|
60
60
|
pathRewrite: { '^/api': '' }
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
+
// 监听文件新增或删除 并重启服务,防止因为文件丢失而编译报错,默认只监听components 目录下的文件,如没有这个目录则不监听, 开启后,文件监听会占用大量cpu,请谨慎使用
|
|
63
64
|
watch: ['./src/components'],
|
|
64
65
|
// 是否启用 https服务
|
|
65
66
|
isHttps: false,
|
|
66
67
|
// 是否启用 dll
|
|
67
68
|
dll: false,
|
|
68
|
-
//
|
|
69
|
+
// 拆包,将第三方库单独打包,默认为{},为默认拆包,可自定义拆包,如:
|
|
69
70
|
commonChunks: {
|
|
70
71
|
"echarts": ["echarts", "zrender"],
|
|
71
72
|
},
|
package/conf/config/index.js
CHANGED
|
@@ -29,7 +29,8 @@ module.exports = {
|
|
|
29
29
|
compression: 'gzip',
|
|
30
30
|
buildDependencies: {
|
|
31
31
|
config: [
|
|
32
|
-
'./build.config.js'
|
|
32
|
+
'./build.config.js',
|
|
33
|
+
...processConfig.cacheBuildDependencies
|
|
33
34
|
]
|
|
34
35
|
}
|
|
35
36
|
},
|
|
@@ -44,7 +45,8 @@ module.exports = {
|
|
|
44
45
|
name: 'local_development',
|
|
45
46
|
buildDependencies: {
|
|
46
47
|
config: [
|
|
47
|
-
'./build.config.js'
|
|
48
|
+
'./build.config.js',
|
|
49
|
+
...processConfig.cacheBuildDependencies
|
|
48
50
|
]
|
|
49
51
|
}
|
|
50
52
|
},
|
package/conf/config/loaders.js
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
var path = require('path')
|
|
2
|
-
var devMode = process.env.NODE_ENV !== 'production'
|
|
3
|
-
var MiniCssExtractPlugin = require('mini-css-extract-plugin')
|
|
1
|
+
var path = require('path');
|
|
2
|
+
var devMode = process.env.NODE_ENV !== 'production';
|
|
3
|
+
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
4
4
|
var { merge } = require('webpack-merge');
|
|
5
|
-
var { utils, processConfig } = require('../options')
|
|
5
|
+
var { utils, processConfig } = require('../options');
|
|
6
|
+
var sassGlobalStyles = '';
|
|
7
|
+
processConfig.sassGlobalStyles.forEach((item) => {
|
|
8
|
+
return sassGlobalStyles += `@import "${item}";`;
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
fs.accessSync(utils.rootPath('src/global.scss'), fs.constants.F_OK);
|
|
12
|
+
sassGlobalStyles += `@import "@/global.scss";`;
|
|
13
|
+
} catch (err) {
|
|
14
|
+
// console.log(err);
|
|
15
|
+
};
|
|
6
16
|
module.exports = [
|
|
7
17
|
{
|
|
8
18
|
test: /\.t|jsx?$/,
|
|
@@ -59,7 +69,18 @@ module.exports = [
|
|
|
59
69
|
}, processConfig.babelLoaderOptions)
|
|
60
70
|
}
|
|
61
71
|
],
|
|
62
|
-
exclude:
|
|
72
|
+
exclude: (modulePath) => {
|
|
73
|
+
// 定义你"强制需要编译"的模块列表
|
|
74
|
+
const includeModules = processConfig.compileDependencies;
|
|
75
|
+
if (modulePath.includes('node_modules')) {
|
|
76
|
+
// 检查当前路径是否包含这些包名
|
|
77
|
+
const shouldInclude = includeModules.some(name =>
|
|
78
|
+
modulePath.includes(`node_modules${path.sep}${name}${path.sep}`));
|
|
79
|
+
return !shouldInclude;
|
|
80
|
+
} else {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
63
84
|
},
|
|
64
85
|
{
|
|
65
86
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
|
|
@@ -122,7 +143,7 @@ module.exports = [
|
|
|
122
143
|
{
|
|
123
144
|
loader: "sass-loader",
|
|
124
145
|
options: merge({
|
|
125
|
-
additionalData:
|
|
146
|
+
additionalData: sassGlobalStyles,
|
|
126
147
|
implementation: require('sass'),
|
|
127
148
|
sassOptions: {
|
|
128
149
|
fiber: false,
|
package/conf/options.js
CHANGED
|
@@ -7,7 +7,9 @@ var argvPort = argvs.indexOf('--port') > -1 ? argvs[argvs.indexOf('--port') + 1]
|
|
|
7
7
|
var {
|
|
8
8
|
watch, port, dll, commonChunks, proxy, eslint, entry,
|
|
9
9
|
nodeMiddleware, publicPath, buildDir, eslintExclude, alias,
|
|
10
|
-
cssLoaderOptions, postcssLoaderOptions, sassLoaderOptions,
|
|
10
|
+
cssLoaderOptions, postcssLoaderOptions, sassLoaderOptions,
|
|
11
|
+
babelLoaderOptions, cacheBuildDependencies, compileDependencies,
|
|
12
|
+
sassGlobalStyles,
|
|
11
13
|
...webpackConfig
|
|
12
14
|
} = userConfig;
|
|
13
15
|
|
|
@@ -34,7 +36,10 @@ exports.processConfig = {
|
|
|
34
36
|
cssLoaderOptions: utils.isObj(cssLoaderOptions) ? cssLoaderOptions : {},
|
|
35
37
|
postcssLoaderOptions: utils.isObj(postcssLoaderOptions) ? postcssLoaderOptions : {},
|
|
36
38
|
sassLoaderOptions: utils.isObj(sassLoaderOptions) ? sassLoaderOptions : {},
|
|
37
|
-
babelLoaderOptions: utils.isObj(babelLoaderOptions) ? babelLoaderOptions : {}
|
|
39
|
+
babelLoaderOptions: utils.isObj(babelLoaderOptions) ? babelLoaderOptions : {},
|
|
40
|
+
cacheBuildDependencies: Array.isArray(cacheBuildDependencies) ? cacheBuildDependencies : [],
|
|
41
|
+
compileDependencies: Array.isArray(compileDependencies) ? compileDependencies : [],
|
|
42
|
+
sassGlobalStyles: Array.isArray(sassGlobalStyles) ? sassGlobalStyles : [],
|
|
38
43
|
};
|
|
39
44
|
|
|
40
45
|
exports.webpackConfig = merge({}, webpackConfig);
|
package/conf/webpack-server.js
CHANGED
|
@@ -30,7 +30,17 @@ if (Array.isArray(processConfig.watch) && processConfig.watch.length > 0) {
|
|
|
30
30
|
module.exports = function startServer() {
|
|
31
31
|
var spinner = ora('Starting dev server...');
|
|
32
32
|
spinner.start();
|
|
33
|
-
childProcess = spawn(
|
|
33
|
+
childProcess = spawn(
|
|
34
|
+
'node',
|
|
35
|
+
['--max_old_space_size=4096', path.join(__dirname, './dev-server.js'), ...process.argv.slice(2)],
|
|
36
|
+
{
|
|
37
|
+
env: Object.assign({}, process.env, {
|
|
38
|
+
NODE_ENV: 'development', // 根据需要修改或添加其它环境变量
|
|
39
|
+
// EXAMPLE_VAR: 'value'
|
|
40
|
+
}),
|
|
41
|
+
stdio: 'pipe'
|
|
42
|
+
}
|
|
43
|
+
);
|
|
34
44
|
|
|
35
45
|
// 监听子进程输出
|
|
36
46
|
childProcess.stdout.on('data', (data) => {
|