I'm having difficulty incorporating Typescript to my JS project which uses webpack. Here is my webpack.config.js:
const MonacoWebpackPlugin = require("monaco-editor-webpack-plugin");
const path = require("path");
module.exports = {
entry: "./src/index.ts",
module: {
rules: [
{
test: /\.css$/,
use: ["style-loader", "css-loader"],
},
{
test: /\.ttf$/,
use: ["file-loader"],
},
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
},
plugins: [new MonacoWebpackPlugin()],
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist"),
},
};
And the tsconfig I'm currently using:
{
"compilerOptions": {
"outDir": "./dist/",
"noImplicitAny": true,
"module": "ES6",
"target": "ES5",
"jsx": "react",
"moduleResolution": "node"
}
}
I run the app with webpack serve --mode development but nothing is appearing in dist/bundle.js. I don't know if its because of the module specified in the tsconfig, or if I need to add an explicit tsc transpilation step, or what.
servecommand might not populate a bundle unless you configure it to. If you omit theserveit will probably output as needed, since that's what you'd be instructing it to do.tsconfigoutDirconfiguration is ignored when you use Webpack or any bundler for that matter. Out of the box, as @JeffBowman said, the Webpack dev server does not emit files during development mode.