Last active
September 28, 2016 16:10
-
-
Save Jhony0311/c7fba8af4b4039959ac6dff7e68c11df to your computer and use it in GitHub Desktop.
FRCSTR - Medium Post - Webpack Conf Prod
This file contains hidden or 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'); | |
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: ['./scripts/app.js'], | |
output: { | |
path: path.resolve(__dirname, 'dist/assets/'), | |
filename: 'scripts/bundle.js', | |
publicPath: '/assets/' | |
}, | |
plugins: [ | |
new CopyWebpackPlugin([ | |
{ from: './assets/images/', to: './images/' }, | |
{ from: './assets/fonts/', to: './fonts/' }, | |
{ from: 'index.html', to: '../' } | |
]), | |
new ExtractTextPlugin('styles/[name].css') | |
], | |
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