🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 1.环境配置webpack ~~~ //设置npm的仓库为淘宝 npm config set registry https://registry.npm.taobao.org //或者安装cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org ~~~ ~~~ npm init -y npm i webpack babel-loader babel-core babel-preset-env --save-dev npm install html-webpack-plugin --save-dev npm i webpack-cli -g ~~~ # 2.webpack.config.js ~~~ var htmlWebpackPlugin = require('html-webpack-plugin'); var path = require('path'); module.exports = { entry : './src/index.js', output: { path:__dirname+'/dist', filename:'js/index.js' }, plugins:[ new htmlWebpackPlugin({ filename:'index.html', template:'index.html', inject:'head' }) ], module:{ rules:[ { test:/\.js$/, use:{loader:'babel-loader'}, exclude: /(node_modules|bower_components)/, include : path.resolve(__dirname,'src') } ] } } ~~~ # 3.项目目录 ![](https://box.kancloud.cn/650aff4b2d54a46c59492a99aaa488b7_386x283.png)