Last active
August 3, 2020 21:22
-
-
Save trinwin/a1ab37f534658aa893c287dabd773f04 to your computer and use it in GitHub Desktop.
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
const path = require('path'); | |
module.exports = { | |
webpackFinal: async (baseConfig, options) => { | |
const { module = {} } = baseConfig; | |
const newConfig = { | |
...baseConfig, | |
module: { | |
...module, | |
rules: [...(module.rules || [])], | |
}, | |
}; | |
// TypeScript | |
newConfig.module.rules.push({ | |
test: /\.(ts|tsx)$/, | |
include: [path.resolve(__dirname, '../components')], | |
use: [ | |
{ | |
loader: 'babel-loader', | |
options: { | |
presets: ['next/babel', require.resolve('babel-preset-react-app')], | |
plugins: ['react-docgen'], | |
}, | |
}, | |
], | |
}); | |
newConfig.resolve.extensions.push('.ts', '.tsx'); | |
// SCSS | |
newConfig.module.rules.push({ | |
test: /\.(s*)css$/, | |
loaders: ['style-loader', 'css-loader', 'sass-loader'], | |
include: path.resolve(__dirname, '../styles/global.scss'), | |
}); | |
// If you are using CSS Modules, check out the setup from Justin (justincy) | |
// Many thanks to Justin for the inspiration | |
// https://gist.github.com/justincy/b8805ae2b333ac98d5a3bd9f431e8f70#file-next-preset-js | |
return newConfig; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment