Skip to content

Instantly share code, notes, and snippets.

@saitonakamura
Last active July 17, 2023 08:52
Show Gist options
  • Save saitonakamura/db05670a637da0247022e9808bc0ec09 to your computer and use it in GitHub Desktop.
Save saitonakamura/db05670a637da0247022e9808bc0ec09 to your computer and use it in GitHub Desktop.
Next.js Awesome Typescript integration: how to add awesome-typescript-loader to Next.js webpack config
module.exports = {
webpack(config, options) {
const { dir, defaultLoaders } = options
config.pageExtensions.push(".ts", ".tsx");
config.resolve.extensions.push(".ts", ".tsx");
config.module.rules.push({
test: /\.tsx?$/,
include: [dir],
exclude: /node_modules/,
use: [
defaultLoaders.babel,
{
loader: "awesome-typescript-loader",,
},
],
});
return config;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment