Skip to content

Instantly share code, notes, and snippets.

@mkelley33
Created November 20, 2016 00:42
Show Gist options
  • Save mkelley33/5a61ac78e8f0c793d25eba00bcf5bd62 to your computer and use it in GitHub Desktop.
Save mkelley33/5a61ac78e8f0c793d25eba00bcf5bd62 to your computer and use it in GitHub Desktop.
webpack-dashboard config
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
// add
const Dashboard = require('webpack-dashboard');
const DashboardPlugin = require('webpack-dashboard/plugin');
const dashboard = new Dashboard();
// add
const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
entry: {
app: './src/main.js',
},
output: {
path: path.resolve(__dirname, './dist'),
// publicPath: '/dist/',
filename: isProduction ? '[name].[chunkhash:6].js' : '[name].js',
},
resolveLoader: {
root: path.join(__dirname, 'node_modules'),
},
vue: {
postcss: [
require('postcss-cssnext')(),
require('postcss-px2rem')(),
],
autoprefixer: false,
},
plugins: [
new DashboardPlugin(dashboard.setData), // add
new HtmlWebpackPlugin({
filename: './index.html',
template: './src/index.html',
inject: 'body',
}),
],
module: {
loaders: [
{
test: /\.vue$/,
loader: 'vue'
},
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.html$/,
loader: 'vue-html'
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'url',
query: {
limit: 10000,
name: '[name].[ext]?[hash]'
}
}
]
},
devServer: {
quiet: true, // add
historyApiFallback: true,
noInfo: true
},
devtool: '#eval-source-map'
}
if (isProduction) {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
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()
])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment