Skip to content

Instantly share code, notes, and snippets.

@macromaniac
Last active October 27, 2015 13:15
Show Gist options
  • Save macromaniac/9c6636f4bf100b4cb353 to your computer and use it in GitHub Desktop.
Save macromaniac/9c6636f4bf100b4cb353 to your computer and use it in GitHub Desktop.
Typescript Webpack with Visual Studio setup, launch via NPM
// SIMPLE VISUAL STUDIO WEBPACK CONFIG
// Auto reloading, Sourcemaps, es6 modules loading, uses visual studio to compile the typescript
// required DevDependencies:
// webpack
// source-map-loader
// browser-sync
// browser-sync-webpack-plugin
// babel-loader
//
// in tsconfig enable sourcemaps and set es6 to true
// run "webpack -wd", or add it to your npm scripts
// To install a library, for example, the library "q":
// npm install q
// tsd install q
// (change the type definition so "export=Q" becomes "export default Q" to work with ES6)
// Use import Q from "q";
// In the future the 3rd and 2nd step will likely not be needed because
// people will package es6 definitions with their libraries (hopefully)
// and you should be able to just "npm install q" => "import Q from "q"" ezpz
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
//EXAMPLE ENTRY POINT, CHANGE THIS:
entry: {
main: "./src/entry.js"
},
output: {
filename: "./wwwroot/[name].bundle.js"
},
//This is to maintain sourcemaps from typescript
module: {
preLoaders: [{ loader: "source-map-loader" }],
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel'
}
]
},
plugins: [
new BrowserSyncPlugin(
// browserSync options
// http://www.browsersync.io/docs/options/
{
host: 'localhost',
port: 3000,
//DEFAULTS TO MONITORING ALL FILES IN WWWROOT
files:"./wwwroot/**/*",
server: { baseDir: ['./wwwroot'] }
//Uncomment proxy if using proxy
//proxy: "localhost:8888"
},
{
name: 'my-awesome-bs-instance'
}
)
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment