From d30e28bfaa692764823841d4f7ce97be2e365c44 Mon Sep 17 00:00:00 2001 From: Noah Loomans Date: Wed, 21 Mar 2018 15:16:19 +0100 Subject: Use css-loader with modules --- webpack.config.js | 40 +++++++++++++++------------------------- 1 file changed, 15 insertions(+), 25 deletions(-) (limited to 'webpack.config.js') diff --git a/webpack.config.js b/webpack.config.js index 0bf982a..573373c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,8 +1,7 @@ const webpack = require('webpack'); const path = require('path'); -const ExtractTextPlugin = require('extract-text-webpack-plugin'); -const js = { +module.exports = { entry: './src/client/react/index.js', output: { path: path.resolve(__dirname, 'src/client/static'), @@ -11,11 +10,24 @@ const js = { module: { rules: [ { - test: [/\.js$/, /\.jsx$/], + test: /\.js$/, exclude: [/node_modules/], loader: 'babel-loader', options: { presets: ['es2015', 'react', 'stage-2'] }, }, + { + test: /\.css/, + use: [ + { loader: 'style-loader' }, + { + loader: 'css-loader', + options: { + modules: true, + localIdentName: '[local]--[name]--[hash:base64:5]', + }, + }, + ], + }, ], }, plugins: [ @@ -24,25 +36,3 @@ const js = { new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /nl/), ], }; - -const style = { - entry: './src/client/style/index.scss', - output: { - path: path.resolve(__dirname, 'src/client/static'), - filename: 'bundle.css', - }, - module: { - rules: [ - { - test: [/\.scss$/], - exclude: [/node_modules/], - loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader']), - }, - ], - }, - plugins: [ - new ExtractTextPlugin('bundle.css'), - ], -}; - -module.exports = [js, style]; -- cgit v1.1