var webpack = require('webpack'), webpackMerge = require('webpack-merge'), ExtractTextPlugin = require('extract-text-webpack-plugin'), runConfig = require('./webpack.run.base.js'), helpers = require('./helpers'); var ENV = process.env.NODE_ENV = process.env.ENV = 'production'; helpers.removeLoaders(runConfig, ['scss', 'png']); module.exports = webpackMerge(runConfig, { devtool: 'source-map', output: { /** * The output directory as absolute path (required). * * See: http://webpack.github.io/docs/configuration.html#output-path */ path: helpers.root('wwwroot/build/'), publicPath: '/build/', /** * Specifies the name of each output file on disk. * IMPORTANT: You must not specify an absolute path here! * * See: http://webpack.github.io/docs/configuration.html#output-filename */ filename: '[name].[hash].js', /** * The filename of non-entry chunks as relative path * inside the output.path directory. * * See: http://webpack.github.io/docs/configuration.html#output-chunkfilename */ chunkFilename: '[id].[hash].chunk.js' }, /* * Options affecting the normal modules. * * See: http://webpack.github.io/docs/configuration.html#module */ module: { /** * An array of automatically applied loaders. * * IMPORTANT: The loaders here are resolved relative to the resource which they are applied to. * This means they are not resolved relative to the configuration file. * * See: http://webpack.github.io/docs/configuration.html#module-loaders */ loaders: [ { test: /\.scss$/, include: helpers.root('app', 'theme'), loader: ExtractTextPlugin.extract({ fallbackLoader: 'style', loader: 'css!sass?sourceMap' }) }, { test: /\.scss$/, exclude: helpers.root('app', 'theme'), loaders: ['raw', helpers.root('app-config', 'clean-css-loader'), 'sass'] }, { test: /\.(png|jpe?g|gif|svg|ico)(\?.*$|$)/, loaders: ['file?hash=sha512&digest=hex&name=assets/[name].[hash].[ext]', 'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false'] } ] }, plugins: [ new webpack.NoErrorsPlugin(), new webpack.DefinePlugin({ 'process.env': { 'ENV': JSON.stringify(ENV) } }), /* * Puts each bundle into a file and appends the hash of the file to the path. * * See: https://github.com/webpack/extract-text-webpack-plugin */ new ExtractTextPlugin('[name].[hash].css'), new webpack.optimize.UglifyJsPlugin({ mangle: { screw_ie8: true, keep_fnames: true } }), ] });