Skip to content

Instantly share code, notes, and snippets.

@joshuacrass
Last active September 12, 2018 07:09
Show Gist options
  • Save joshuacrass/af3be5311f8b96a866dfb0282b22bf50 to your computer and use it in GitHub Desktop.
Save joshuacrass/af3be5311f8b96a866dfb0282b22bf50 to your computer and use it in GitHub Desktop.
Webpack style config
module: {
rules: [
{
// look for .js or .jsx files
test: /\.(js|jsx)$/,
// in the `src` directory
include: path.resolve(paths.appSrc),
exclude: /(node_modules)/,
use: {
// use babel for transpiling JavaScript files
loader: 'babel-loader',
options: {
presets: ['@babel/react'],
},
},
},
{
// look for .css or .scss files
test: /\.(css|scss)$/,
// in the `src` directory
include: [path.resolve(paths.appSrc)],
use: [
{
loader: 'style-loader',
},
{
loader: 'css-loader',
options: {
discardDuplicates: true,
importLoaders: 1,
// This enables local scoped CSS based in CSS Modules spec
modules: true,
// generates a unique name for each class (e.g. app__app___2x3cr)
localIdentName: '[name]__[local]___[hash:base64:5]',
sourceMap: process.env.NODE_ENV !== 'production',
},
},
{
loader: 'sass-loader',
options: {
sourceMap: process.env.NODE_ENV !== 'production',
},
},
],
},
],
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment