2016-08-10 05:15:44 +00:00
|
|
|
require('es6-promise').polyfill();
|
|
|
|
|
2019-07-29 16:40:16 +00:00
|
|
|
const path = require('path');
|
|
|
|
const webpack = require('webpack');
|
|
|
|
const bourbon = require('node-bourbon').includePaths;
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const WebpackNotifierPlugin = require('webpack-notifier');
|
2016-08-10 05:15:44 +00:00
|
|
|
|
|
|
|
var plugins = [
|
2017-03-13 19:13:33 +00:00
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
2017-01-19 15:24:10 +00:00
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: '../frontend/templates/react.tmpl',
|
2017-01-19 17:14:43 +00:00
|
|
|
inject: false,
|
2017-01-19 15:24:10 +00:00
|
|
|
template: 'frontend/templates/react.ejs'
|
2017-03-13 19:13:33 +00:00
|
|
|
}),
|
|
|
|
new WebpackNotifierPlugin({
|
2019-01-24 17:39:32 +00:00
|
|
|
title: "Fleet",
|
2017-03-13 19:13:33 +00:00
|
|
|
contentImage: path.resolve("./assets/images/kolide-logo.svg"),
|
|
|
|
excludeWarnings: true
|
2017-01-19 15:24:10 +00:00
|
|
|
})
|
2016-08-10 05:15:44 +00:00
|
|
|
];
|
|
|
|
|
2017-01-19 15:24:10 +00:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
plugins = plugins.concat([
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {NODE_ENV: JSON.stringify('production')}
|
|
|
|
}),
|
2019-07-29 16:40:16 +00:00
|
|
|
new MiniCssExtractPlugin({ filename: 'bundle-[contenthash].css', allChunks: false })
|
2017-01-19 15:24:10 +00:00
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
plugins = plugins.concat([
|
2019-07-29 16:40:16 +00:00
|
|
|
new MiniCssExtractPlugin({ filename: 'bundle.css', allChunks: false })
|
2017-01-19 15:24:10 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2016-09-05 21:58:49 +00:00
|
|
|
var repo = __dirname
|
2016-08-10 15:31:27 +00:00
|
|
|
|
2016-08-10 05:15:44 +00:00
|
|
|
var config = {
|
2019-07-29 16:40:16 +00:00
|
|
|
mode: process.env.NODE_ENV,
|
2016-08-10 05:15:44 +00:00
|
|
|
entry: {
|
2016-09-07 00:04:02 +00:00
|
|
|
bundle: path.join(repo, 'frontend/index.jsx')
|
2016-08-10 05:15:44 +00:00
|
|
|
},
|
|
|
|
output: {
|
2016-09-13 19:50:37 +00:00
|
|
|
path: path.join(repo, 'assets/'),
|
2016-08-10 05:15:44 +00:00
|
|
|
publicPath: "/assets/",
|
|
|
|
filename: '[name].js'
|
|
|
|
},
|
|
|
|
plugins: plugins,
|
2019-07-29 16:40:16 +00:00
|
|
|
optimization: {
|
|
|
|
minimize: process.env.NODE_ENV == 'production',
|
|
|
|
},
|
2016-08-10 05:15:44 +00:00
|
|
|
module: {
|
2016-12-13 18:35:46 +00:00
|
|
|
// 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/,
|
2017-03-13 19:13:33 +00:00
|
|
|
rules: [
|
|
|
|
{ test: /\.(png|gif)$/, use: { loader: 'url-loader?name=[name]@[hash].[ext]&limit=6000' } },
|
2019-10-16 23:40:45 +00:00
|
|
|
{
|
|
|
|
test: /\.(pdf|ico|jpg|svg|eot|otf|woff|woff2|ttf|mp4|webm)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: '[name]@[hash].[ext]',
|
|
|
|
useRelativePath: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2017-03-13 19:13:33 +00:00
|
|
|
{ test: /\.tsx?$/, exclude: /node_modules/, use: { loader: 'ts-loader' } },
|
2016-11-03 19:40:54 +00:00
|
|
|
{
|
|
|
|
test: /\.scss$/,
|
|
|
|
exclude: /node_modules/,
|
2019-07-29 16:40:16 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
2019-10-16 23:40:45 +00:00
|
|
|
publicPath: './',
|
2019-07-29 16:40:16 +00:00
|
|
|
hmr: process.env.NODE_ENV == 'development',
|
|
|
|
},
|
|
|
|
},
|
2017-03-13 19:13:33 +00:00
|
|
|
{ loader: 'css-loader' },
|
2019-01-03 20:46:55 +00:00
|
|
|
{ loader: 'postcss-loader' },
|
2017-03-13 19:13:33 +00:00
|
|
|
{
|
|
|
|
loader: 'sass-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
includePaths: [ bourbon ]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{ loader: 'import-glob-loader' }
|
2019-07-29 16:40:16 +00:00
|
|
|
],
|
2016-11-03 19:40:54 +00:00
|
|
|
},
|
2016-09-23 18:04:01 +00:00
|
|
|
{
|
2016-10-21 15:57:33 +00:00
|
|
|
test: /\.css$/,
|
2019-07-29 16:40:16 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
options: {
|
|
|
|
hmr: process.env.NODE_ENV == 'development',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'css-loader',
|
|
|
|
'postcss-loader'
|
|
|
|
],
|
2016-09-23 18:04:01 +00:00
|
|
|
},
|
2016-08-10 05:15:44 +00:00
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
2016-08-10 15:31:27 +00:00
|
|
|
include: path.join(repo, 'frontend'),
|
2017-03-13 19:13:33 +00:00
|
|
|
use: [ 'babel-loader' ]
|
2016-08-10 05:15:44 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
resolve: {
|
2017-03-13 19:13:33 +00:00
|
|
|
extensions: ['.js', '.jsx', '.json'],
|
|
|
|
modules: [
|
|
|
|
path.resolve(path.join(repo, './frontend')),
|
|
|
|
"node_modules"
|
2016-08-10 05:15:44 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-01-19 15:24:10 +00:00
|
|
|
if (process.env.NODE_ENV === 'production') {
|
|
|
|
config.output.filename = "[name]-[hash].js"
|
|
|
|
}
|
|
|
|
|
2016-08-10 05:15:44 +00:00
|
|
|
module.exports = config;
|