Created
August 31, 2016 15:59
-
-
Save matyax/c898c39545a96bdfaab9b5a3e2656e33 to your computer and use it in GitHub Desktop.
Webpack development config file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'), | |
webpack = require('webpack'), | |
HtmlWebpackPlugin = require('html-webpack-plugin'), | |
OpenBrowserPlugin = require('open-browser-webpack-plugin'), | |
ExtractTextPlugin = require('extract-text-webpack-plugin'), | |
precss = require('precss'), | |
autoprefixer = require('autoprefixer'), | |
DashboardPlugin = require('webpack-dashboard/plugin'); | |
mockMode = false; | |
process.argv.forEach((param) => { | |
if (param === '--mock') { | |
mockMode = true; | |
} | |
}); | |
module.exports = { | |
entry: [ | |
'webpack-dev-server/client?http://127.0.0.1:8080', | |
'webpack/hot/dev-server', | |
path.resolve(__dirname, 'src/index.js') | |
], | |
output: { | |
path: path.join(__dirname, 'dist'), | |
filename: 'bundle.js', | |
publicPath: '/' | |
}, | |
plugins: [ | |
new ExtractTextPlugin('reference-app.css'), | |
new webpack.HotModuleReplacementPlugin(), | |
new HtmlWebpackPlugin({ | |
template: './src/index.pug' | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'views/index.html', | |
template: './src/views/index.pug' | |
}), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'MOCK': mockMode | |
} | |
}), | |
new OpenBrowserPlugin({ url: 'http://127.0.0.1:8080' }), | |
new DashboardPlugin() | |
], | |
resolve: { | |
extensions: ['', '.js', 'css'], | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.pug$/, | |
loader: 'pug' | |
}, | |
{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract( | |
'style-loader', | |
'css-loader!postcss-loader' | |
) | |
}, | |
{ | |
test: /\.js$/, | |
include: path.resolve(__dirname, 'src'), | |
exclude: '/node_modules', | |
loader: 'babel-loader', | |
query: { | |
presets: [ | |
'es2015', | |
'stage-0' | |
], | |
plugins: [ | |
'transform-decorators-legacy', | |
'transform-class-properties' | |
] | |
} | |
} | |
] | |
}, | |
devServer: { | |
contentBase: './dist', | |
hot: true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment