Skip to content

Instantly share code, notes, and snippets.

@mmitou
Last active June 20, 2021 09:37
Show Gist options
  • Save mmitou/b3238024f9cafbfb86e9bbd3b1292466 to your computer and use it in GitHub Desktop.
Save mmitou/b3238024f9cafbfb86e9bbd3b1292466 to your computer and use it in GitHub Desktop.
ブラウザ用typescriptの設定
{
"name": "webpack-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths-webpack-plugin": "^3.5.1",
"typescript": "^4.3.4",
"webpack": "^5.39.1",
"webpack-cli": "^4.7.2"
}
}
{
"compilerOptions": {
"target": "es2020",
"module": "esnext",
"lib": ["es2020", "dom"],
"sourceMap": true,
"rootDir": "src",
"baseUrl": "src",
"moduleResolution": "node",
"strict": true,
"allowUnreachableCode": false
},
"include": ["./src/**/*"]
}
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
module.exports = {
mode: "development",
devtool: "inline-source-map",
entry: "./src/index.ts",
module: {
rules: [
{
test: /\.ts$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
modules: [path.resolve(__dirname, "src"), "node_modules"],
// .ts と .jsがないとModuleエラー
extensions: [".ts", ".js"],
plugins: [new TsconfigPathsPlugin({ configFile: "tsconfig.json" })],
},
output: {
filename: "bundle.js",
},
experiments: {
topLevelAwait: true,
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment