Last active
March 3, 2016 20:27
-
-
Save dbismut/5da989d6b4331f20ae44 to your computer and use it in GitHub Desktop.
Webpack config
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 webpack = require('webpack'); | |
var ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
var babelSettings = { presets: ['react', 'es2015', 'stage-0'] }; | |
babelSettings.plugins = ['transform-decorators-legacy']; | |
if (process.env.NODE_ENV !== 'production' && !process.env.IS_MIRROR) { | |
babelSettings.plugins.push(['react-transform', { | |
transforms: [{ | |
transform: 'react-transform-hmr', | |
imports: ['react'], | |
locals: ['module'] | |
}, { | |
transform: 'react-transform-catch-errors', | |
imports: ['react', 'redbox-react'] | |
}] | |
// redbox-react is breaking the line numbers :-( | |
// you might want to disable it | |
}]); | |
} | |
var cssLoader; | |
var plugins = []; | |
if (process.env.NODE_ENV === 'production') { | |
/* loading analytics */ | |
plugins.push(new webpack.DefinePlugin({GA_TRACKING_CODE: JSON.stringify('UA-XXXXXXXXX-1')})); | |
plugins.push(new ExtractTextPlugin('style.css', { | |
allChunks: true | |
})); | |
cssLoader = ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[hash:base64:5]!postcss'); | |
if (!Meteor.isCordova) { | |
plugins.push(new webpack.optimize.CommonsChunkPlugin('common', 'common.web.js')); | |
} | |
} | |
else { | |
cssLoader = 'style!css?modules&importLoaders=1&localIdentName=[name]__[local]__[hash:base64:5]!postcss'; | |
} | |
module.exports = { | |
entry: './entry', | |
plugins: plugins, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
loader: 'babel', | |
query: babelSettings, | |
exclude: /node_modules/ | |
}, | |
{ | |
test: /\.css$/, | |
loader: cssLoader | |
}, | |
{ | |
test: /\.(png|jpe?g|svg)(\?.*)?$/i, | |
loaders: [ | |
'file?hash=sha512&digest=hex&name=[hash].[ext]', | |
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' | |
// 'url?limit=8182' | |
] | |
}, | |
{ test: /\.(ttf|woff|eot)(\?.*)?$/i, loader: 'file' } | |
] | |
}, | |
postcss: function (webpack) { | |
return [ | |
require('postcss-import')({ | |
addDependencyTo: webpack | |
}), | |
require('postcss-cssnext'), | |
// require('postcss-nesting'), | |
require('postcss-at2x') | |
]; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment