-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvue.config.js
94 lines (92 loc) · 2.3 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* @张
* @time 2019-10-29
*
*/
const path = require("path");
const SkeletonWebpackPlugin = require("vue-skeleton-webpack-plugin");
const prerenderSpaPlugin = require("prerender-spa-plugin");
// BundleAnalyzerPlugin 打包分析代码大小
//const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
// .BundleAnalyzerPlugin;
module.exports = {
configureWebpack: config => {
if (process.env.NODE_ENV === "production") {
// 为生产环境修改的
} else {
// 为开发环境修改的
}
return {
/**
* externals模块提供webpack打包的cdn 写发
* @module externals
* 有顺序 : 非vue系组件一定要在vue 之前 ,vue系一定要vue之后.
*
*/
externals: {
axios: "axios",
rxjs: "rxjs",
vue: "Vue",
"vue-rx": "VueRx",
vuex: "Vuex",
"vue-router": "VueRouter",
swiper: "Swiper"
},
plugins: [
/**
* @SkeletonWebpackPlugin 骨架屏
*/
new SkeletonWebpackPlugin({
webpackConfig: {
entry: {
app: path.resolve("./src/config/entry.js")
}
}
}),
/**
* @prerenderSpaPlugin 首屏渲染
*/
new prerenderSpaPlugin({
staticDir: path.join(__dirname, "dist"),
routes: ["/", "/about"]
}) //,
// new BundleAnalyzerPlugin()
],
/**
* @alias别名
* 提供在vue打包用的绝对路径(必须上)
* 需要引用path模块
*/
resolve: {
alias: {
"@config": path.resolve(__dirname, "./src/config"),
"@css": path.resolve(__dirname, "./src/assets/css"),
"@view": path.resolve(__dirname, "./src/view"),
"@img": path.resolve(__dirname, "./src/assets/img"),
"@com": path.resolve(__dirname, "./src/components"),
"@ajax": path.resolve(__dirname, "./src/config/ajax")
}
}
};
}
};
/*{
webpackConfig: {
entry: {
app: path.join((__dirname, "./scr/skeleton.js"))
},
router: {
mode: "history",
routes: [
{
path: "/",
skeletonId: "skeleton1"
},
{
path: "/about",
skeletonId: "skeleton2"
}
]
}
}
}*/