-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
31 lines (31 loc) · 1.3 KB
/
postcss.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
module.exports = ({ file }) => {
const path = require("path");
const isUview = file && file.dirname && file.dirname.indexOf("uview-ui") > -1;
const rootValue = isUview ? 375 : 750; // 判断条件 请自行调整
return {
parser: require("postcss-comment"),
plugins: [
require("postcss-import")({
resolve(id, basedir, importOptions) {
console.log("Postcss配置:", basedir, importOptions);
if (id.startsWith("~@/")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3));
} else if (id.startsWith("@/")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2));
} else if (id.startsWith("/") && !id.startsWith("//")) {
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1));
}
return id;
}
}),
require("autoprefixer")({
remove: process.env.UNI_PLATFORM !== "h5"
}),
require("@dcloudio/vue-cli-plugin-uni/packages/postcss"),
require("postcss-pxtransform")({
platform: "weapp",
designWidth: rootValue
})
]
};
};