-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathvue.config.doc-entry.js
59 lines (52 loc) · 1.99 KB
/
vue.config.doc-entry.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
const chainCSSOneOfs = require('vue-cli-plugin-vusion/webpack/chainCSSOneOfs');
module.exports = {
outputDir: 'dist-doc-entry',
chainWebpack(config) {
config.entryPoints.clear();
config.entry('index')
.add(require.resolve('vue-cli-plugin-vusion/scenes/doc/views/docEntry.js'));
config.output.filename('[name].js')
.library('doc-entry')
.libraryTarget('window');
config.externals({
vue: 'Vue',
'cloud-ui.vusion': 'CloudUI',
});
if (config.plugins.has('extract-css')) { // Build mode
chainCSSOneOfs(config, (oneOf, modules) => {
oneOf.use('extract-css-loader')
.options({
publicPath: './',
hmr: false,
});
});
config.plugin('extract-css').tap(([options]) => {
options.filename = '[name].css';
return [options];
// themeFilename: 'css/[name]-theme-[theme].css',
// themes: Object.keys(vusionConfig.theme),
});
}
if (config.plugins.has('icon-font-plugin')) { // && !vueConfig.publicPath) {
config.plugin('icon-font-plugin')
.tap(([options]) => {
options.publicPath = './fonts'; // @TODO: this option is weird
return [options];
});
}
// 关掉 url(./img/xxx) -> url(img/xxx) 的处理
config.plugin('optimize-css').tap(([options]) => {
if (!options.cssnanoOptions.preset[1])
options.cssnanoOptions.preset[1] = {};
options.cssnanoOptions.preset[1].normalizeUrl = false;
options.cssnanoOptions.preset[1].calc = false;
return [options];
});
config.optimization.splitChunks({
cacheGroups: {
vendors: false,
default: false,
},
});
},
};