配置webpack.config.js:
const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); module.exports = { entry: __dirname + '/src/main.js', output: { path: __dirname + '/build', filename: 'bundle.js' }, devtool: 'eval-source-map', //调试工具 devServer: { contentBase: './build', historyApiFallback: true, //不跳转 inline: true //实时刷新 }, watch: true, //自动监听,修改后自动编译 resolve: { extensions: ['.js', '.vue', '.json'], alias: { 'vue$': 'vue/dist/vue.esm.js' } }, module: { rules: [{ test: /.vue$/, use: 'vue-loader' }, { test: /.js$/, use: 'babel-loader' }, { test: /.css$/, use: [{ loader: "style-loader" //计算样式插入页面 }, { loader: "css-loader" //@import等导入样式 } ] } ] }, plugins: [ new webpack.BannerPlugin('Create by Jabin'), new HtmlWebpackPlugin({ template: __dirname + '/src/index.tpl.html' }) ] }
.babelrc
{ "presets": [ "stage-2" ] }
注意:json已集成,无需转换