-
Notifications
You must be signed in to change notification settings - Fork 109
/
vue.config.js
87 lines (81 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
75
76
77
78
79
80
81
82
83
84
85
86
87
// eslint-disable-next-line @typescript-eslint/no-var-requires
const merge = require("webpack-merge");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const tsImportPluginFactory = require("ts-import-plugin");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const pxtoviewport = require("postcss-px-to-viewport");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require("path");
function resolve(dir) {
return path.join(__dirname, dir);
}
const { VantResolver } = require("unplugin-vue-components/resolvers");
const ComponentsPlugin = require("unplugin-vue-components/webpack");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const autoprefixer = require("autoprefixer");
module.exports = {
parallel: false,
css: {
loaderOptions: {
//配置less主题
less: {
lessOptions: {
modifyVars: {
// 直接覆盖变量
"text-color": "#111",
"border-color": "#eee",
// 或者可以通过 less 文件覆盖(文件路径为绝对路径)
hack: `true; @import "./src/theme/var.less";`
}
}
},
//配置路vw vm适配
postcss: {
plugins: [
autoprefixer(),
pxtoviewport({
viewportWidth: 375
})
]
}
}
},
//配置路径别名
configureWebpack: {
plugins: [
ComponentsPlugin({
resolvers: [VantResolver()]
})
],
resolve: {
alias: {
"@": resolve("src"),
"@assets": resolve("src/assets")
}
}
},
chainWebpack: config => {
config.module
.rule("ts")
.use("ts-loader")
.tap(options => {
options = merge(options, {
transpileOnly: true,
getCustomTransformers: () => ({
before: [
tsImportPluginFactory({
libraryName: "vant",
libraryDirectory: "es",
style: name => `${name}/style/less`
// style: true
})
]
}),
compilerOptions: {
module: "es2015"
}
});
return options;
});
}
};