Skip to content

Instantly share code, notes, and snippets.

@pavtaras
Created May 15, 2017 07:08
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 pavtaras/c80dd5ce020281afb3b08c288b121465 to your computer and use it in GitHub Desktop.
Save pavtaras/c80dd5ce020281afb3b08c288b121465 to your computer and use it in GitHub Desktop.
Webpack config for AngularJS apps
var webpack = require('webpack'),
path = require('path');
module.exports = function(env){
env = env || {};
var isProd = env.isProd || false;
var config = {
context: path.resolve("./src"),
entry: {
app: './modules/app/app.module.js',
vendor: ['angular', 'angular-ui-router'],
},
output: {
path: path.resolve('./public/js'),
publicPath: '/js/',
filename: '[name].js'
},
module: {
rules: [
{ test: /\.html$/, use: { loader: 'html-loader', options: {minimize: true}}},
{ test: require.resolve('angular'), use: 'exports-loader?window.angular'}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
chunks: ['app', 'vendor'],
name: 'vendor'
}),
new webpack.ProvidePlugin({
angular: 'angular'
}),
new webpack.DefinePlugin({
PRODUCTION: JSON.stringify(isProd)
})
],
devtool: 'source-map',
devServer: {
contentBase: path.resolve('./public'),
port: 9000,
}
};
return config;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment