framework-for-vue
v1.0.4
Published
framework for vue2
Downloads
1
Readme
framework-for-vue
介绍
framework-for-vue
安装教程
- npm install -D framework-for-vue
使用说明
- 这是一个针对vue2,使用webpack5进行打包的简洁工具包,包含babel预置v7,各种预置loader,vue-router等工具,开箱即用
- 使用示例
*** dev.js ***
const { webpackConfig, devServerConfig, startServer } = require('framework-for-vue');
// modify loader, eg: vue-loader
webpackConfig.module.rules.forEach(i => {
if (i.test.toString() == /\.vue$/) {
// todo vue
}
});
// copywebpack plugin
webpackConfig.plugins.push(
new CopyWebpackPlugin({
patterns: [
{ from: 'xxx', to: 'xxx' },
]
})
);
devServerConfig.port = '8080';
devServerConfig.host = '127.0.0.1';
devServerConfig.proxy = {
'/': {
target: 'http://x.xx.xxx/api', // 后端接口
secure: false, // 是否验证SSl证书
changeOrigin: true,
bypass: function(req, res, proxyOptions) {
console.log(proxyOptions.target, req.originalUrl)
}
}
};
// start dev server on host:port
startServer(webpackConfig, devServerConfig);
*** build.js ***
const { webpackConfig } = require('framework-for-vue');
// modify loader, eg: vue-loader
webpackConfig.module.rules.forEach(i => {
if (i.test.toString() == /\.vue$/) {
// todo vue
}
});
// copywebpack plugin
webpackConfig.plugins.push(
new CopyWebpackPlugin({
patterns: [
{ from: 'xxx', to: 'xxx' },
]
})
);
module.exports = webpackConfig;
*** package.json ***
"script": {
"dev": "cross-env NODE_ENV=development node ./dev.js",
"build": "cross-env NODE_ENV=production webpack --config ./build.js",
}