Created
February 16, 2016 05:10
-
-
Save jem-computer/f69ca9bfbb260a66061d 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
/** | |
* COMMON WEBPACK CONFIGURATION | |
*/ | |
const path = require('path') | |
const webpack = require('webpack') | |
module.exports = (options) => { | |
return { | |
entry: options.entry, | |
output: { // Compile into js/build.js | |
path: path.resolve(__dirname, '..', 'public', 'build'), | |
filename: '[name].js', | |
chunkFilename: '[name].chunk.js', | |
publicPath: '/build/' | |
}, | |
module: { | |
loaders: [{ | |
test: /\.js$/, // Transform all .js files required somewhere with Babel | |
loader: 'babel', | |
exclude: path.join(__dirname, '..', '/node_modules/'), | |
query: options.babelQuery | |
}, { | |
test: /\.css$/, // Transform all .css files required somewhere with PostCSS | |
loader: options.cssLoaders | |
}, { | |
test: /\.jpe?g$|\.gif$|\.png$/i, | |
loader: 'url-loader?limit=10000' | |
}, { | |
test: /\.html$/, | |
loader: 'html-loader' | |
} | |
] | |
}, | |
plugins: options.plugins.concat([ | |
new webpack.optimize.CommonsChunkPlugin('common.js') | |
]), | |
postcss: function () { | |
return [ | |
require('postcss-import')({ | |
glob: true, | |
onImport: function (files) { | |
console.log(this) | |
files.forEach(this.addDependency) | |
}.bind(this) | |
}), | |
require('postcss-custom-media'), | |
require('postcss-custom-properties'), | |
require('postcss-calc'), | |
require('postcss-color-function'), | |
require('postcss-discard-comments'), | |
require('postcss-focus')(), // ...add a :focus to ever :hover... | |
require('autoprefixer')({ // ...and add vendor prefixes... | |
browsers: ['last 2 versions', 'IE > 8'] // ...supporting the last 2 major browser versions and IE 8 and up... | |
}), | |
require('postcss-reporter')({ // Posts messages from plugins to the terminal | |
clearMessages: true | |
}) | |
] | |
}, | |
resolve: { | |
modulesDirectories: [ | |
'assets', | |
'containers', | |
'components', | |
'node_modules' | |
], | |
extensions: [ | |
'', | |
'.js', | |
'.jsx', | |
'.react.js' | |
] | |
}, | |
target: 'web', // Make web variables accessible to webpack, e.g. window | |
stats: false, // Don't show stats in the console | |
progress: true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment