Last active
January 21, 2019 00:00
-
-
Save hmsk/07cb73692dc141262dd1093783b731d8 to your computer and use it in GitHub Desktop.
Simple module to use TypeScript on Nuxt
This file contains hidden or 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
export default function () { | |
// Nuxt resolves .ts extension | |
this.nuxt.options.extensions.push('ts') | |
// Extend webpack build | |
this.extendBuild(config => { | |
// Add ts-loader to import .ts | |
config.module.rules.push({ | |
test: /\.ts$/, | |
loader: 'ts-loader', | |
options: { appendTsSuffixTo: [/\.vue$/] } | |
}) | |
// Webpack resolves .ts extension | |
if (! config.resolve.extensions.includes('.ts')) { | |
config.resolve.extensions.push('.ts') | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment