forked from vusion-templates/admin-cloud-fs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvusion.config.js
74 lines (72 loc) · 2.42 KB
/
vusion.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 path = require('path');
const webpack = require('webpack');
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
const manifest = process.env.NODE_ENV === 'production' ? require('./dll/vendor.manifest.json') : require('./dll/vendor.dev.manifest.json');
const vendorPath = process.env.NODE_ENV === 'production' ? path.resolve(__dirname, 'dll/vendor.js') : path.resolve(__dirname, 'dll/vendor.dev.js');
module.exports = {
version: '>=0.8.1',
type: 'app',
staticPath: './static/',
srcPath: './client/',
docs: false,
extractCSS: false,
sourceMap: false,
resolvePriority: 'current',
entry: {
prepend: ['babel-polyfill', 'whatwg-fetch'],
pages: ['index', 'dashboard', 'login'],
commons: true,
},
webpack: {
output: {
path: path.resolve(__dirname, 'public'),
publicPath: '/public/',
},
resolve: {
alias: {
vue$: path.resolve(__dirname, 'node_modules/vue/dist/vue.esm.js'),
'vue-router$': path.resolve(__dirname, 'node_modules/vue-router/dist/vue-router.esm.js'),
'@': path.resolve(__dirname, 'client'),
services: path.resolve(__dirname, 'client/services'),
},
},
module: {
rules: [{
test: /\.js$/,
use: ['source-map-loader'],
enforce: 'pre',
}],
},
plugins: [
// 关联生成的 dll 信息文件
new webpack.DllReferencePlugin({
manifest,
}),
// 将 vendor.js 带上 hash 并注入到 html 中
new AddAssetHtmlPlugin({
filepath: vendorPath,
hash: true,
includeSourcemap: false,
}),
],
},
webpackDevServer: {
// host: 'http://localhost',
port: 9090,
publicPath: '/public/',
contentBase: path.resolve(__dirname, 'public'),
proxy: [{
context: '/api',
target: 'http://localhost:7000',
}, {
context: ['/', '/dashboard', '/index', '/login'],
target: 'http://localhost:9090',
pathRewrite: (path) => {
if (path === '/')
return '/public/index.html';
else
return '/public' + path + '.html';
},
}],
},
};