Answer the question
In order to leave comments, you need to log in
Why doesn't webpack.config.ts find __dirname?
The config/
folder contains the webpack.config.ts file , I run it with webpack.config.js :
require('ts-node').register({
project: 'tsconfig.tsnode.json'
});
module.exports = require('./config/webpack.config').default;
import * as path from "path";
import * as webpack from "webpack";
const projectRootPath = path.resolve(__dirname, '../');
const config = webpack.Configuration = {
context: path.resolve(__dirname, '..'),
entry: ["./src/app.tsx"],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, './public/js'),
publicPath: path.resolve(__dirname, '/public/')
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: '/node_modules/',
use: {
loader: "ts",
presets: ['react']
}
}
]
},
resolve: {
extensions: ["*", ".webpack.js", ".jsx", ".ts", ".tsx", ".js"]
},
watch: true
};
export default config;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question