Skip to content

Instantly share code, notes, and snippets.

@petyosi
Created February 9, 2018 13:36
Show Gist options
  • Save petyosi/0f67c4aee8d047ee64264f7f4fcd1fdf to your computer and use it in GitHub Desktop.
Save petyosi/0f67c4aee8d047ee64264f7f4fcd1fdf to your computer and use it in GitHub Desktop.
const path = require('path');
const webpack = require('webpack');
const helpers = require('./helpers');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const ENV = process.env.NODE_ENV = process.env.ENV = 'production';
module.exports = {
entry: {
polyfills: './app/polyfills.ts',
vendor: './app/vendor-aot.ts',
app: './app/boot-aot.ts'
},
output: {
path: helpers.root('dist/aot'),
publicPath: '/',
filename: '[name].bundle.js',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['.js', '.ts']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: '@ngtools/webpack'
},
{
test: /\.html$/,
loader: 'html-loader'
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
// AOT Plugin
new AotPlugin({
tsConfigPath: './tsconfig.aot.json',
entryModule: helpers.root('app/app.module#AppModule')
}),
new HtmlWebpackPlugin({
template: 'config/index.html'
}),
new webpack.optimize.UglifyJsPlugin({
beautify: false,
comments: false,
compress: {
screw_ie8: true,
warnings: false
},
mangle: {
keep_fnames: true,
screw_i8: true
}
}),
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