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