const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const config = { entry: './main', //入口文件 output: { //node.js中__dirname变量获取当前模块文件所在目录的完整绝对路径 path: path.join(__dirname, "./dist"), //输出位置 publicPath: "/dist", filename: 'js/main.js' //输入文件 }, module: { rules: [ { test: /\.js$/, loader: "babel-loader", exclude: /node_modules/ }, { test: /\.css$/, use: ExtractTextPlugin.extract({ use: "css-loader", fallback: "style-loader" }) }, { test: /\.vue$/, loader: "vue-loader", options: { loaders: { css: ExtractTextPlugin.extract({ use: "css-loader", fallback: "vue-style-loader" }) } } } ] }, plugins: [ new ExtractTextPlugin("css/styles.css") ], //必须要加上,不然使用组件不显示 resolve: { alias: {'vue': './node_modules/vue/dist/vue.js'} } }; module.exports = config;
resolve: { alias: {'vue': './node_modules/vue/dist/vue.js'} }
这一行是必须加上的,参考:
http://blog.csdn.net/fengjingyu168/article/details/72911421