Last active
February 28, 2016 16:07
-
-
Save natac13/8b8a2e735b416915fff2 to your computer and use it in GitHub Desktop.
Webpack Config file. Produciton
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
import path from 'path' | |
import webpack from 'webpack' | |
import autoprefixer from 'autoprefixer' | |
import ExtractTextPlugin from 'extract-text-webpack-plugin' | |
import HtmlWebpackPlugin from 'html-webpack-plugin' | |
const buildPath = path.join(__dirname, 'build') | |
const entry = path.join(__dirname, 'app', 'index.js') | |
module.exports = { | |
// real source-map for production | |
devtool: 'source-map', | |
entry: [ | |
// sets up an ES6-ish environment with promise support | |
'babel-polyfill', | |
// the main application script | |
entry | |
], | |
output: { | |
path: buildPath, | |
filename: 'bundle.js' | |
}, | |
resolve: { | |
extensions: ['', '.js', '.jsx', '.css', '.scss', '.json', '.node', '.png'] | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules)/, | |
loader: 'babel', | |
query: { | |
cacheDirectory: true, | |
presets: ['es2015', 'stage-0', 'react'] | |
} | |
}, | |
{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader') | |
}, | |
{ | |
test: /\.scss$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass!toolbox') | |
}, | |
{ | |
test: /\.json$/, | |
loader: 'json' | |
}, | |
{ | |
test: /\.node$/, | |
loader: 'node-loader' | |
}, | |
{ | |
test: /\.(jpe?g|png|gif)$/, | |
loaders: [ | |
'file?hash=sha512&digest=hex&name=[name]_[hash].[ext]', | |
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' | |
] | |
}, | |
{ | |
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'url-loader?limit=10000&mimetype=application/font-woff' | |
}, | |
{ | |
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'file-loader' | |
} | |
] | |
}, | |
postcss: [autoprefixer], | |
toolbox: { theme: 'theme.scss' }, | |
plugins: [ | |
new ExtractTextPlugin('style.css', { allChunk: true }), | |
new HtmlWebpackPlugin({ | |
template: './app/index.html' | |
}), | |
new webpack.optimize.DedupePlugin(), | |
new webpack.optimize.UglifyJsPlugin({ | |
minimize: true, | |
compress: { | |
warnings: false | |
} | |
}), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify('production') | |
} | |
}) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment