fleet/webpack.config.js

119 lines
3.3 KiB
JavaScript
Raw Normal View History

require('es6-promise').polyfill();
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
2016-10-21 15:57:33 +00:00
var bourbon = require('node-bourbon').includePaths;
var WebpackBuildNotifierPlugin = require('webpack-build-notifier');
2017-01-19 15:24:10 +00:00
var HtmlWebpackPlugin = require('html-webpack-plugin');
var plugins = [
new webpack.NoErrorsPlugin(),
new webpack.optimize.DedupePlugin(),
2017-01-19 15:24:10 +00:00
new HtmlWebpackPlugin({
filename: '../frontend/templates/react.tmpl',
inject: false,
2017-01-19 15:24:10 +00:00
template: 'frontend/templates/react.ejs'
})
];
if (process.argv.indexOf('--notify') > -1) {
plugins = plugins.concat([
new WebpackBuildNotifierPlugin({
title: "Kolide",
logo: path.resolve("./assets/images/kolide-logo.svg"),
suppressWarning: true,
suppressSuccess: true,
sound: false
})
])
};
2017-01-19 15:24:10 +00:00
if (process.env.NODE_ENV === 'production') {
plugins = plugins.concat([
new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
output: {comments: false}
}),
new webpack.DefinePlugin({
'process.env': {NODE_ENV: JSON.stringify('production')}
}),
new ExtractTextPlugin("bundle-[contenthash].css", {allChunks: false})
]);
} else {
plugins = plugins.concat([
new ExtractTextPlugin("bundle.css", {allChunks: false})
]);
}
var repo = __dirname
2016-08-10 15:31:27 +00:00
var config = {
entry: {
2016-09-07 00:04:02 +00:00
bundle: path.join(repo, 'frontend/index.jsx')
},
output: {
path: path.join(repo, 'assets/'),
publicPath: "/assets/",
filename: '[name].js'
},
plugins: plugins,
module: {
// The following noParse suppresses the warning about sqlite-parser being a
// pre-compiled JS file. See https://goo.gl/N4s6bB.
noParse: /node_modules\/sqlite-parser\/dist\/sqlite-parser-min.js/,
loaders: [
2016-09-08 12:50:44 +00:00
{test: /\.(png|gif)$/, loader: 'url-loader?name=[name]@[hash].[ext]&limit=6000'},
{test: /\.(pdf|ico|jpg|svg|eot|otf|woff|ttf|mp4|webm)$/, loader: 'file-loader?name=[name]@[hash].[ext]'},
{test: /\.json$/, loader: 'raw-loader'},
2016-10-31 21:02:06 +00:00
{test: /\.tsx?$/, exclude: /node_modules/, loader: 'ts-loader'},
{
test: /\.scss$/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract('style-loader', 'css!sass?sourceMap=true&includePaths[]=' + bourbon + '!import-glob')
},
{
2016-10-21 15:57:33 +00:00
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!autoprefixer-loader')
},
{
test: /\.jsx?$/,
2016-08-10 15:31:27 +00:00
include: path.join(repo, 'frontend'),
loaders: ['babel']
}
]
},
resolve: {
extensions: ['', '.js', '.jsx', '.json'],
root: [
path.resolve(path.join(repo, './frontend'))
]
},
svgo1: {
multipass: true,
plugins: [
// by default enabled
{mergePaths: false},
{convertTransform: false},
{convertShapeToPath: false},
{cleanupIDs: false},
{collapseGroups: false},
{transformsWithOnePath: false},
{cleanupNumericValues: false},
{convertPathData: false},
{moveGroupAttrsToElems: false},
// by default disabled
{removeTitle: true},
{removeDesc: true}
]
}
};
2017-01-19 15:24:10 +00:00
if (process.env.NODE_ENV === 'production') {
config.output.filename = "[name]-[hash].js"
}
module.exports = config;