Created
May 15, 2017 07:08
-
-
Save pavtaras/c80dd5ce020281afb3b08c288b121465 to your computer and use it in GitHub Desktop.
Webpack config for AngularJS apps
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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