Created
November 3, 2019 02:03
-
-
Save joebobmiles/5f8510f64c714399e3e86a93f7218655 to your computer and use it in GitHub Desktop.
Basic project configs for a TypeScript and WebPack project. (Requires TypeScript, WebPack, and WebPack CLI to be installed!)
This file contains 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": { | |
"outDir": "./dist/", | |
"rootDir": "./src/", | |
"sourceMap": true, | |
"noImplicitAny": true, | |
"module": "commonjs", | |
"target": "es5" | |
} | |
} |
This file contains 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
// This config has the following MANDATORY NPM dependencies: | |
// ts-loader, source-map-loader | |
// And the following OPTIONAL dependency: | |
// webpack-dev-server. | |
module.exports = { | |
mode: "development", | |
devtool: "source-map", | |
resolve: { | |
// We include ".js" for the sake of the WebPack development | |
// server. If we don't, the dev server fails to compile. | |
extensions: [".ts", ".tsx", ".js"] | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /\.ts(x?)$/, | |
exclude: /node_modules/, | |
use: [ | |
{ | |
// This needs to be installed: | |
// `npm i --save-dev ts-loader` | |
loader: "ts-loader" | |
} | |
] | |
}, | |
{ | |
enforce: "pre", | |
test: /\.js$/, | |
// This needs to be installed: | |
// `npm i --save-dev source-map-loader` | |
loader: "source-map-loader" | |
} | |
] | |
}, | |
// This is for webpack-dev-server (`npm i --save-dev webpack-dev-server`) | |
devServer: { | |
compress: true, | |
port: 80 | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment