Last active
          June 20, 2021 09:37 
        
      - 
      
 - 
        
Save mmitou/b3238024f9cafbfb86e9bbd3b1292466 to your computer and use it in GitHub Desktop.  
    ブラウザ用typescriptの設定
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | { | |
| "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" | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              Show hidden characters
| { | |
| "compilerOptions": { | |
| "target": "es2020", | |
| "module": "esnext", | |
| "lib": ["es2020", "dom"], | |
| "sourceMap": true, | |
| "rootDir": "src", | |
| "baseUrl": "src", | |
| "moduleResolution": "node", | |
| "strict": true, | |
| "allowUnreachableCode": false | |
| }, | |
| "include": ["./src/**/*"] | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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