forked from vusion-templates/cloud-admin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vue.config.js
74 lines (67 loc) · 2.19 KB
/
vue.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const pkg = require('./package.json');
const pages = require('./pages.json');
const argv = require('minimist')(process.argv.slice(2));
if (argv.pages) {
argv.pages = argv.pages.split(',');
Object.keys(pages).forEach((key) => {
if (!argv.pages.includes(key))
delete pages[key];
});
}
if (Object.keys(pages).length > 1) {
Object.keys(pages).forEach((key) => {
if (pages[key].micro) {
console.warn(`page[${key}] is microApp`);
delete pages[key];
}
});
}
const isDevelopment = process.env.NODE_ENV === 'development';
const publicPathPrefix = process.env.SITE_TYPE === 'gh-pages' ? `https://vusion-templates.github.io/${pkg.name}` : '/';
const port = argv.port || 8810;
const devServer = require('./webpack.dev-server')(port);
const webpackMicro = require('./webpack/micro');
const isMicro = webpackMicro.isMicro(pages);
const webpackDll = require('./webpack/dll');
const webpackStyle = require('./webpack/style');
const webpackRoutes = require('./webpack/routes');
const webpackHtml = require('./webpack/html');
const webpackOptimization = require('./webpack/optimization');
if (isMicro) {
webpackMicro.setup(pages);
}
const assetsDir = 'public';
let baseConfig = {
publicPath: publicPathPrefix,
assetsDir,
productionSourceMap: false,
transpileDependencies: [
/lodash/,
'resize-detector',
/cloud-ui\.vusion/,
/vusion-micro-app/,
/@cloud-ui/,
],
};
if (isMicro) {
baseConfig = webpackMicro.config(baseConfig, port, isDevelopment);
}
const vueConfig = {
...baseConfig,
pages,
chainWebpack(config) {
webpackHtml.chain(config, isDevelopment);
webpackOptimization.chain(config, isDevelopment, pages);
if (isMicro) {
webpackMicro.chain(config, isDevelopment);
} else {
webpackDll.chain(config, publicPathPrefix, isDevelopment);
}
webpackStyle.chain(config);
webpackRoutes.chain(config);
config.output.jsonpFunction('webpackJsonp' + pkg.name + (isMicro ? Object.keys(pages)[0] : ''));
config.module.rule('js').uses.delete('cache-loader');
},
devServer,
};
module.exports = vueConfig;