Created
July 24, 2015 03:00
-
-
Save wbuchwalter/576975608120bf2f107d to your computer and use it in GitHub Desktop.
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
//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