Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Commit b2373e1

Browse files
Support Webpack configs authored in TypeScript. Covers #1301
1 parent 08c2f23 commit b2373e1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: src/Microsoft.AspNetCore.SpaServices/npm/aspnet-webpack/src/WebpackDevMiddleware.ts

+9
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,15 @@ function beginWebpackWatcher(webpackConfig: webpack.Configuration) {
237237
export function createWebpackDevServer(callback: CreateDevServerCallback, optionsJson: string) {
238238
const options: CreateDevServerOptions = JSON.parse(optionsJson);
239239

240+
// Enable TypeScript loading if the webpack config is authored in TypeScript
241+
if (path.extname(options.webpackConfigPath) === '.ts') {
242+
try {
243+
require('ts-node/register');
244+
} catch (ex) {
245+
throw new Error('Error while attempting to enable support for Webpack config file written in TypeScript. Make sure your project depends on the "ts-node" NPM package. The underlying error was: ' + ex.stack);
246+
}
247+
}
248+
240249
// See the large comment in WebpackTestPermissions.ts for details about this
241250
if (!hasSufficientPermissions()) {
242251
console.log('WARNING: Webpack dev middleware is not enabled because the server process does not have sufficient permissions. You should either remove the UseWebpackDevMiddleware call from your code, or to make it work, give your server process user account permission to write to your application directory and to read all ancestor-level directories.');

0 commit comments

Comments
 (0)