I've configured my webpack using typescript files instead of javascript. All works finw with webpack but when I execute the app the following exception is thrown:
Exception: Call to Node module failed with error: C:\Code\VisualStudioProjects\CaliUp\CaliUp\webpack.config.ts:1
(function (exports, require, module, __filename, __dirname) { import * as path from 'path';
Did you support typescrit webpack config files? Is there any way to configure it?
If you're talking about the Webpack dev middleware, then sorry, there's no out-of-the-box support for that. I'm not sure how exactly you configured the webpack CLI tool to work with TypeScript (since that's not something it supports out-of-the-box either) but if you come up with a clean and simple implementation that would work for Webpack dev middleware then please let us know!
You might be able to pull it off by registering ts-node at the top.
require('ts-node/register')
It is actually supported.
https://stackoverflow.com/questions/40075269/is-it-possible-to-write-webpack-config-in-typescript
Also @MarkPieszak solution works. It may be a good idea to add the line conditionally: if ts-node exists
or load ts-node depending on environment variable.
I am ready to work on a PR if needed.
EDIT:
As temporary workaround create a js file (webpack.dev.js):
require('ts-node/register')
module.exports = require("./webpack.config.ts");
Then
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
ConfigFile = "webpack.dev.js"
...
Most helpful comment
It is actually supported.
https://stackoverflow.com/questions/40075269/is-it-possible-to-write-webpack-config-in-typescript
Also @MarkPieszak solution works. It may be a good idea to add the line conditionally: if ts-node exists
or load ts-node depending on environment variable.
I am ready to work on a PR if needed.
EDIT:
As temporary workaround create a js file (webpack.dev.js):
require('ts-node/register')
module.exports = require("./webpack.config.ts");
Then
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
ConfigFile = "webpack.dev.js"
...