Skip to content

Instantly share code, notes, and snippets.

@Jhony0311
Last active September 28, 2016 16:03
Show Gist options
  • Save Jhony0311/14c1e8bff54732bd476fe16fb9f58688 to your computer and use it in GitHub Desktop.
Save Jhony0311/14c1e8bff54732bd476fe16fb9f58688 to your computer and use it in GitHub Desktop.
FRCSTR - Medium Post - Webpack Config
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, 'client'),
devtool: 'source-map',
entry: ['webpack/hot/dev-server', './scripts/app.js'],
output: {
path: path.resolve(__dirname, 'dist/assets/'),
filename: 'scripts/bundle.js',
publicPath: '/assets/'
},
resolve: {
root: path.resolve('./app/scripts'),
extensions: ['', '.js']
},
devServer: {
contentBase: 'client',
host: 'localhost',
port: '9000',
hot: true,
inline: true,
stats: 'errors-only'
},
watchOptions: {
aggregateTimeout: 300,
poll: 1000
},
plugins: [
new ExtractTextPlugin('styles/[name].css'),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new CopyWebpackPlugin([
{ from: 'images/', to: 'images/' },
{ from: 'fonts/', to: 'fonts/' }
])
],
module: {
loaders: [
// js
{
test: /\.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'client')
},
// CSS
{
test: /\.scss$/,
include: path.join(__dirname, 'client'),
loader: ExtractTextPlugin.extract('style', [
'css?sourceMap',
'postcss',
'sass?sourceMap&outputStyle=expanded'
].join('!'))
}, {
test: /\.(png|jpg|svg|gif|eot|ttf|woff|woff2)$/,
exclude: /node_modules/,
loader: 'url-loader'
}
]
},
postcss: function() {
return [autoprefixer({
browsers: ['last 2 versions']
})];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment