vue-cli-plugin-eplus
Version:
vue-cli plugin to init eplus template
77 lines (70 loc) • 1.87 kB
JavaScript
module.exports = (api, options = {}) => {
const utils = require('./utils')(api);
api.render('./template/common');
api.extendPackage({
dependencies: {
axios: '^0.21.1'
},
devDependencies: {
sass: '^1.26.5',
'sass-loader': '^8.0.2',
'@vue/eslint-config-prettier': '^6.0.0'
},
scripts: {
'build:test': 'vue-cli-service build --mode test',
'build:production': 'vue-cli-service build --mode production',
},
});
if (options.mobile) {
api.render('./template/mobile');
api.extendPackage({
devDependencies: {
'postcss-pxtorem': '^5.1.1'
}
});
}
if (options.react) {
api.render('./template/react');
api.extendPackage({
dependencies: {
clsx: '^1.1.1',
react: '^17.0.2',
'react-dom': '^17.0.2',
'react-router-dom': '^5.2.0'
},
devDependencies: {
'eslint-plugin-react': '^7.23.2',
'@babel/preset-react': '^7.13.13',
'@types/react': '^17.0.3',
'@types/react-dom': '^17.0.3',
'@types/react-router-dom': '^5.1.7'
}
});
}
if (options.lodash) {
api.extendPackage({
dependencies: {
lodash: '^4.17.21'
},
devDependencies: {
'babel-plugin-lodash': '^3.3.4'
}
});
}
api.onCreateComplete(() => {
if (options.react) {
utils.updateBabelConfig(cfg => {
cfg.presets = cfg.presets || [];
cfg.presets = Array.from(new Set([...cfg.presets, '@babel/preset-react']));
return cfg;
});
}
if (options.lodash) {
utils.updateBabelConfig(cfg => {
cfg.plugins = cfg.plugins || [];
cfg.plugins = Array.from(new Set([...cfg.plugins, 'lodash']));
return cfg;
});
}
});
};