Skip to content

Instantly share code, notes, and snippets.

@mreis1
Created June 22, 2016 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mreis1/11b6b6be16e753a0f4ff4e2dfc50bc37 to your computer and use it in GitHub Desktop.
Save mreis1/11b6b6be16e753a0f4ff4e2dfc50bc37 to your computer and use it in GitHub Desktop.
Webpack Configuration
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"declaration": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
{
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160317120654",
"jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
"node": "registry:dt/node#4.0.0+20160509154515"
}
}
module.exports = {
//...
resolve: {
//...
alias: {
'lessFolder': './../less',
'vendorDir': './../vendor',
'mocksFolder': './../assets/mocks',
'modernizr$': path.resolve(__dirname, "../.modernizrrc")
}
},
module: {
loaders: [
//convert .ts into .js
{
test: /\.ts$/,
loader: 'ts'
},
//html files
{
test: /\.html$/,
loader: 'html'
},
{
test:/\.modernizrrc$/,
loader: "modernizr"
}
]
},
plugins: [
//...
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery",
"_": "underscore",
"underscore": "underscore"
//'process.env.NODE_ENV': '"development"'
}),
//https://github.com/peerigon/modernizr-loader#modernizr-loader-for-webpack
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin('bower.json', ['main'])
),
new HtmlWebpackPlugin({
template: 'src/index.html'
})
]
};
module.exports = webpackMerge(commonConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: helpers.root('dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
devServer: {
historyApiFallback: true,
stats: 'minimal'
}
});
module.exports = webpackMerge(commonConfig, {
devtool: 'source-map',
output: {
path: helpers.root('dist'),
publicPath: '/',
filename: '[name].[hash].js',
chunkFilename: '[id].[hash].chunk.js'
},
htmlLoader: {
minimize: false // workaround for ng2
},
plugins: [
//https://github.com/webpack/docs/wiki/list-of-plugins#noerrorsplugin
new webpack.NoErrorsPlugin(),
//https://github.com/webpack/docs/wiki/list-of-plugins#dedupeplugin
new webpack.optimize.DedupePlugin(),
//https://github.com/webpack/docs/wiki/list-of-plugins#uglifyjsplugin
new webpack.optimize.UglifyJsPlugin(),
//https://github.com/webpack/extract-text-webpack-plugin#usage-example-with-css
new ExtractTextPlugin('[name].[hash].css'),
//https://webpack.github.io/docs/list-of-plugins.html#defineplugin
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment