Skip to content

Instantly share code, notes, and snippets.

@fay-jai
Created March 21, 2016 06:22
Show Gist options
  • Save fay-jai/a50cb2616a8a42731999 to your computer and use it in GitHub Desktop.
Save fay-jai/a50cb2616a8a42731999 to your computer and use it in GitHub Desktop.
Getting Started with Typescript, ReactJS, and Webpack
var path = require("path");
var config = {
/*
* app.ts represents the entry point to your web application. Webpack will
* recursively go through every "require" statement in app.ts and
* efficiently build out the application's dependency tree.
*/
entry: ["./src/app.tsx"],
/*
* The combination of path and filename tells Webpack what name to give to
* the final bundled JavaScript file and where to store this file.
*/
output: {
path: path.resolve(__dirname, "build"),
filename: "bundle.js"
},
/*
* resolve lets Webpack now in advance what file extensions you plan on
* "require"ing into the web application, and allows you to drop them
* in your code.
*/
resolve: {
extensions: ["", ".ts", ".tsx", ".js"]
},
module: {
/*
* Each loader needs an associated Regex test that goes through each
* of the files you've included (or in this case, all files but the
* ones in the excluded directories) and finds all files that pass
* the test. Then it will apply the loader to that file. I haven't
* installed ts-loader yet, but will do that shortly.
*/
loaders: [
{
test: /\.tsx?$/,
loader: "ts-loader",
exclude: /node_modules/
}
]
}
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment