Created
February 27, 2016 01:20
-
-
Save imjakechapman/f88c0ed73674a4d1f6a7 to your computer and use it in GitHub Desktop.
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
| import path from 'path'; | |
| import webpack from 'webpack'; | |
| import ExtractTextPlugin from 'extract-text-webpack-plugin'; | |
| import BundleTracker from 'webpack-bundle-tracker'; | |
| import autoprefixer from 'autoprefixer'; | |
| const PATHS = { | |
| WEB: path.resolve(__dirname, process.env.WEB_PATH), | |
| DIST: path.resolve(__dirname, process.env.DIST_PATH), | |
| SRC: path.resolve(__dirname, process.env.SRC_PATH) | |
| }; | |
| const sassLoaders = [ | |
| 'css-raw-loader?source-map', | |
| 'postcss-loader', | |
| 'sass-loader' | |
| ]; | |
| export default { | |
| devtool: 'source-map', | |
| entry: { | |
| sample: ['./js/main.js'] | |
| }, | |
| output: { | |
| path: PATHS.DIST, | |
| publicPath: '/static/dist/', | |
| filename: '[name].[chunkhash].js' | |
| }, | |
| module: { | |
| loaders: [{ | |
| test: /\.scss$/, | |
| loader: ExtractTextPlugin.extract("style-loader", sassLoaders.join('!')) | |
| }, { | |
| test: /\.js$/, | |
| exclude: /(node_modules|bower_components)/, | |
| loaders: ['babel'] | |
| }] | |
| }, | |
| postcss: [ | |
| autoprefixer({ | |
| browsers: ['last 2 versions'] | |
| }) | |
| ], | |
| plugins: [ | |
| new ExtractTextPlugin("[name].[chunkhash].css"), | |
| new webpack.optimize.UglifyJsPlugin({ | |
| compress: { | |
| warnings: false | |
| } | |
| }), | |
| new BundleTracker({ | |
| path: PATHS.DIST, | |
| filename: 'webpack-stats.json' | |
| }), | |
| // Exit Plugin to process.exit(1) | |
| function() { | |
| this.plugin("done", (stats) => { | |
| if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf('--watch') === -1) { | |
| process.on('beforeExit', () => { | |
| process.exit(1); | |
| }); | |
| } | |
| }); | |
| } | |
| ] | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment