Skip to content

Instantly share code, notes, and snippets.

@ctolkien
Created June 3, 2015 13:00
Show Gist options
  • Save ctolkien/719c6ce5861c9155289c to your computer and use it in GitHub Desktop.
Save ctolkien/719c6ce5861c9155289c to your computer and use it in GitHub Desktop.
ASP.Net 5 Gulp + Webpack
var gulp = require('gulp');
var webpack = require('gulp-webpack');
var ts = require('gulp-typescript');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var dnx = require("gulp-dnx");
gulp.task('webpack', function(){
return gulp.src('./src/client/main.ts')
.pipe(webpack({
output:{
filename:'bundle.js'
},
devtool: 'source-map',
resolve: {
extensions:['','.js','.ts']
},
module:{
loaders: [
{ test: /\.ts$/, loader: 'ts-loader' },
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style-loader", "css-loader") },
{
test: /\.scss$/, loader: ExtractTextPlugin.extract(
// activate source maps via loader query
'css?sourceMap!' +
'sass?sourceMap'
)
},
{ test: /\.jpg$/, loader: 'file-loader'},
{ test:/\.gif$/, loader:'file-loader'},
{ test:/\.png$/, loader:'file-loader'},
{ test: /\.(ttf|eot|svg|woff)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: "file-loader" }
]
},
externals:{
"io":"io"
},
plugins: [
new ExtractTextPlugin("commune.css", {
allChunks: true
})
]
}))
.pipe(gulp.dest('wwwroot/'));
});
gulp.task("dnx-run", dnx('web', { restore: false, build:false }));
gulp.task("default", ['webpack', 'dnx-run']);
gulp.task('watch', ["default"], function(){
gulp.watch('src/client/**/*.ts', ["webpack"]);
gulp.watch('src/client/**/*.scss', ["webpack"]);
gulp.watch('./**/*.cs', ["dnx-run"]);
});
@alexsandro-xpt
Copy link

The webpack.config.js is replaceable by this gulp task?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment