Skip to content

Instantly share code, notes, and snippets.

@wbuchwalter
Created July 24, 2015 03:00
Show Gist options
  • Save wbuchwalter/576975608120bf2f107d to your computer and use it in GitHub Desktop.
Save wbuchwalter/576975608120bf2f107d to your computer and use it in GitHub Desktop.
//webpack.base.config.js
//----------------------------
module.exports = {
entry: {
app: ['./index.html'],
vendor: [
"angular",
"lodash"
]
},
output: {
path: path.join(__dirname, '../build'),
filename: "bundle.js"
},
plugins: [
new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js"),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }),
new webpack.HotModuleReplacementPlugin()
],
resolve: {
extensions: ['', '.ts', '.webpack.js', '.web.js', '.js']
},
devtool: 'source-map',
module: {
preLoaders: [
{ test: /\.ts$/, loader: 'tslint' }
],
loaders: [
{ test: /\.ts$/, loader: 'ts' },
{ test: /\.css$/, loader: "style!css" },
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' },
{ test: /\.(woff|woff2)$/, loader: "url?limit=10000&mimetype=application/font-woff" },
{ test: /\.ttf$/, loader: "url?limit=10000&mimetype=application/octet-stream" },
{ test: /\.eot$/, loader: "file" },
{ test: /\.svg$/, loader: "svg-inline-loader" },
{ test: /\.scss$/, loader: "style!css!sass" },
{ test: /\.html$/, loader: 'html' },
{ test: /rules.json/, loader: 'raw' },
{ test: /data.json/, loader: 'json' }
]
},
tslint: {
emitErrors: false,
failOnHint: false
},
merge: function (customConfig) {
return _.merge(customConfig, this, function (a, b) {
if (_.isArray(a)) {
return a.concat(b);
}
});
}
};
//webpack.test.config.js
//--------------------------------
var baseConfig = require('./webpack.base.config.js');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var path = require("path");
var customConfig = {
entry: {
vendor: ['mocha', 'webpack/hot/dev-server'],
app: ["./src/tests/test_index.ts"]
},
module: {
noParse: [
/sinon/
]
},
plugins: [
new HtmlWebpackPlugin({
title: 'Test',
inject: true,
template: './src/tests/test_index.html'
}),
new webpack.NormalModuleReplacementPlugin(/sinon/, path.join(__dirname, "../node_modules/sinon/pkg/sinon-1.14.1.js"))
]
};
module.exports = baseConfig.merge(customConfig);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment