Skip to content

Instantly share code, notes, and snippets.

@chyngyz
Created May 29, 2016 09:03
Show Gist options
  • Save chyngyz/55b387446d5ecb4b9bfd302033154592 to your computer and use it in GitHub Desktop.
Save chyngyz/55b387446d5ecb4b9bfd302033154592 to your computer and use it in GitHub Desktop.
Angular + Webpack Production Config
'use strict';
var webpack = require('webpack');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
context: __dirname + '/src',
entry: './app/app.js',
output: {
path: __dirname + '/dist',
filename: 'assets/js/bundle.js'
},
devtool: 'cheap-module-source-map',
module: {
loaders: [
{
test: /\.js$/, loader: 'ng-annotate?add=true&map=false!babel', exclude: '/node_modules/'
},
{
test: /\.html$/, loader: 'raw', exclude: '/node_modules/'
},
{
test: /\.scss$/, loader: ExtractTextPlugin.extract(
'style',
'css?sourceMap!resolve-url!sass?sourceMap=true&sourceMapContents=true',
{
publicPath: '../../'
}
), exclude: '/node_modules/'
},
{
test: /\.(png|jpg|jpeg|gif|ico)$/, loader: 'file?name=assets/images/[hash].[ext]'
},
{
test: /\.((woff2?|svg)(\?v=[0-9]\.[0-9]\.[0-9]))|(woff2?|svg)$/, loader: "url?limit=10000&name=assets/fonts/[name].[hash].[ext]"
},
{
test: /\.((ttf|eot)(\?v=[0-9]\.[0-9]\.[0-9]))|(ttf|eot)$/, loader: "file?name=assets/fonts/[name].[hash].[ext]"
}
]
},
plugins: [
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin(),
new HtmlWebpackPlugin({
template: './index.html',
inject: 'body'
}),
new ExtractTextPlugin('assets/styles/[name].[hash].css'),
new CopyWebpackPlugin([{
from: __dirname + '/src/assets',
to: __dirname + '/dist/assets'
}], {
ignore: ['*.scss','fonts/**/*']
})
]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment