const webpack = require('webpack'); const path = require('path'); const autoprefixer = require('autoprefixer'); const lost = require('lost'); const ExtractTextPlugin = require("extract-text-webpack-plugin"); module.exports = { entry: { app: './app/app.js', vendor: ['vue', 'axios', 'vuex', 'debounce', 'vue-router'] }, output: { path: path.resolve('../public/assets'), filename: 'app.js' }, resolve: { alias: { vue$: 'vue/dist/vue.common' } }, module: { loaders: [ { test: /\.vue$/, loader: 'vue' }, { test: /\.js$/, loader: 'babel', exclude: /node_modules/ }, { test: /\.(png|jpg|svg)$/, loader: 'url', query: { limit: 10000, name: 'img/[name].[ext]', emitFile: false } }, { test: /\.scss$/, loader: ExtractTextPlugin.extract('style', 'css!postcss!sass') } ] }, postcss() { return [autoprefixer, lost]; }, plugins: [ new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.js'), new ExtractTextPlugin('app.css') ] }; if(process.env.NODE_ENV === 'production') { module.exports.plugins = (module.exports.plugins || []).concat([ new webpack.DefinePlugin({ 'process.env': { NODE_ENV: '"production"' } }), new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), new webpack.optimize.OccurenceOrderPlugin() ]) }