Skip to content

Instantly share code, notes, and snippets.

@kapowaz
Created January 5, 2022 12:38
Show Gist options
  • Save kapowaz/86f4b45c8e0b9f65b01093fbe6f3eaa9 to your computer and use it in GitHub Desktop.
Save kapowaz/86f4b45c8e0b9f65b01093fbe6f3eaa9 to your computer and use it in GitHub Desktop.
Use typings-for-css-modules-loader with Next.js, SCSS and CSS Modules
const withSass = require('@zeit/next-sass');
module.exports = withSass({
webpack: (config) => {
const scssRule = config.module.rules.find(({ test }) => String(test) === String(/\.scss$/));
if (config.mode === 'development' && config.name === 'client') {
scssRule.use.unshift({
loader: require.resolve('@teamsupercell/typings-for-css-modules-loader'),
});
}
return config;
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment