influxdb/ui/webpack/prodConfig.js

114 lines
3.1 KiB
JavaScript

/* eslint-disable no-var */
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var HtmlWebpackPlugin = require("html-webpack-plugin");
var package = require('../package.json');
var dependencies = package.dependencies;
var config = {
bail: true,
devtool: 'eval',
entry: {
app: path.resolve(__dirname, '..', 'src', 'index.js'),
vendor: Object.keys(dependencies),
},
output: {
publicPath: '/',
path: path.resolve(__dirname, '../build'),
filename: '[name].[chunkhash].js',
},
resolve: {
alias: {
app: path.resolve(__dirname, '..', 'app'),
src: path.resolve(__dirname, '..', 'src'),
shared: path.resolve(__dirname, '..', 'src', 'shared'),
style: path.resolve(__dirname, '..', 'src', 'style'),
utils: path.resolve(__dirname, '..', 'src', 'utils'),
},
},
module: {
preLoaders: [
{
test: /\.js$/,
exclude: [/node_modules/, /(_s|S)pec\.js$/],
loader: 'eslint-loader',
},
],
loaders: [
{
test: /\.json$/,
loader: 'json',
},
{
test: /\.scss$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!sass-loader!resolve-url!sass?sourceMap'),
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader'),
},
{
test : /\.(ico|png|cur|jpg|ttf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader : 'file',
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-0'],
cacheDirectory: false, // Using the cache directory on production builds has never been helpful.
},
},
],
},
eslint: {
failOnWarning: false,
failOnError: false,
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production'),
},
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
}),
new ExtractTextPlugin("chronograf.css"),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '..', 'src', 'index.template.html'),
inject: 'body',
chunksSortMode: 'dependency',
favicon: 'assets/images/favicon.ico',
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest'],
}),
function() { /* Webpack does not exit with non-zero status if error. */
this.plugin("done", function(stats) {
if (stats.compilation.errors && stats.compilation.errors.length && process.argv.indexOf("--watch") == -1) {
console.log(stats.compilation.errors.toString({
colors: true
}));
process.exit(1);
}
});
},
new webpack.DefinePlugin({
VERSION: JSON.stringify(require('../package.json').version),
}),
],
postcss: require('./postcss'),
target: 'web',
};
module.exports = config;