static-cms/webpack.base.js
Andrey Okonetchnikov fed0066ca5 Use proper loaders for external module's CSS. (#157)
- react-toolbox requires its own setup with sass-loader for now
- redux-notifications doen's need to use css-modules
- exclude `node_modules` from our own CSS pipeline

Realted to bcca98b1951d03e0850b353e9c16fd8b1db2291f
2016-11-23 16:22:49 -02:00

58 lines
1.7 KiB
JavaScript

/* eslint global-require: 0 */
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
module: {
loaders: [
{
loader: 'babel',
test: /\.js?$/,
exclude: /node_modules/,
},
{
/* CSS loader for npm modules that are shipped with CSS.
List all of theme in the array
*/
test: /\.css$/,
include: [/redux-notifications/],
loader: ExtractTextPlugin.extract('style', 'css'),
},
{
/* React-toolbox still relies on SCSS and css-modules */
test: /\.scss$/,
include: [/react-toolbox/],
loader: ExtractTextPlugin.extract('style', 'css?modules!sass'),
},
{
/* We use CSS-modules and PostCSS for CMS styles */
test: /\.css$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&&localIdentName=cms__[name]__[local]!postcss'),
},
{
test: /\.(png|eot|woff|woff2|ttf|svg|gif)(\?v=\d+\.\d+\.\d+)?$/,
loader: 'url-loader?limit=10000',
},
{
test: /\.json$/,
loader: 'json-loader',
},
],
},
postcss: [
require('postcss-import')({ addDependencyTo: webpack }),
require('postcss-cssnext')({
browsers: ['last 2 versions', 'IE > 10'],
}),
],
plugins: [
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), // Ignore all optional deps of moment.js
new webpack.ProvidePlugin({
fetch: 'imports?this=>global!exports?global.fetch!whatwg-fetch',
}),
],
target: 'web', // Make web variables accessible to webpack, e.g. window
};