preset.json
{
"useConfigFiles": true,
"cssPreprocessor": "sass",
"plugins": {
"@vue/cli-plugin-babel": {},
"@vue/cli-plugin-eslint": {
"config": "standard",
"lintOn": ["save", "commit"]
}
},
"configs": {
"vue": {
"productionSourceMap": false
},
"postcss": {
"plugins": {
"postcss-pxtorem":{
"rootValue": 75,
"unitPrecision": 5,
"propList": ["*"],
"selectorBlackList": ["ignore"],
"replace": true,
"mediaQuery": false,
"minPixelValue": 0
}
}
},
"eslintConfig": {
"globals": {
"WebViewJavascriptBridge": true,
"wx": true,
"_czc": true
},
"rules": {
"generator-star-spacing": "off",
"no-mixed-spaces-and-tabs": "off",
"no-tabs": "off"
}
},
"babelConfig": {
"plugins": [
"lodash",
["import", {
"libraryName": "vant",
"libraryDirectory": "es",
"style": true
}]
]
}
}
}
generator.js
module.exports = (api, options, rootOptions) => {
if (options.wechartEnv) {
console.log('需要在微信环境中进行使用')
}
if (options.needLinkme) {
console.log('需要使用深度链接功能')
}
// 插件通用配置项
api.extendPackage({
dependencies: {
axios: '^0.18.0',
vant: '^1.1.15',
'vue-router': '^3.0.1',
vuex: '^3.0.1'
},
devDependencies: {
"babel-plugin-lodash": "^3.3.4",
"lodash": "^4.17.10",
"lodash-webpack-plugin": "^0.11.5",
"postcss-aspect-ratio-mini": "^0.0.2",
"postcss-bem": "^0.4.1",
"postcss-import": "^12.0.0",
"postcss-pxtorem": "^4.0.1",
"postcss-url": "^8.0.0"
}
})
api.render('./template')
}