Skip to content

Instantly share code, notes, and snippets.

@joeeames
Created July 23, 2017 03:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeeames/c399d2d58dc91dd452238815858f5b4a to your computer and use it in GitHub Desktop.
Save joeeames/c399d2d58dc91dd452238815858f5b4a 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 ENV = process.env.NODE_ENV = process.env.ENV = 'development';
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: {
'polyfills': './public/polyfills.ts',
'vendor': './public/vendor.ts',
'app': './public/main.ts',
'ng1': './public/index.ts'
},
output: {
path: helpers.root('dist/dev'),
publicPath: '/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.html$/,
loader: 'html-loader'
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: 'common'
// name: ['app', 'vendor', 'polyfills', 'ng1']
}),
new HtmlWebpackPlugin({
template: 'public/index.html'
}),
new webpack.DefinePlugin({
'process.env': {
'ENV': JSON.stringify(ENV)
}
})
]
};
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': './public/polyfills.ts',
'vendor': './public/vendor-aot.ts',
'app': './public/main-aot.ts',
'ng1': './public/index.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: 'common'
// name: ['app', 'vendor', 'polyfills', 'ng1']
}),
new AotPlugin({
tsConfigPath: './tsconfig.aot.json',
entryModule: helpers.root('public/app/app.module#AppModule')
}),
new HtmlWebpackPlugin({
template: 'public/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