Build was previously at a ridiculous 903,456 bytes.
Restructured config to have entirely separate production settings
without any hotloader stuff in the way, dropping it to 132,015 bytes.
This is still too big, as the app is just a production build of React,
11 small JS modules, and a CSS file, but it's a big improvement.
import gulp from 'gulp';
import gutil from 'gulp-util';
import mocha from 'gulp-spawn-mocha';
+import productionConfig from './webpack.production.config.js';
import webpack from 'webpack';
let watching = false;
});
gulp.task('webpack:build', callback => {
- const myConfig = {
- ...config,
- plugins: config.plugins.concat(
- new webpack.DefinePlugin({
- 'process.env': {
- NODE_ENV: JSON.stringify('production'),
- },
- }),
- new webpack.optimize.DedupePlugin(),
- new webpack.optimize.UglifyJsPlugin()
- ),
- };
-
- webpack(myConfig, (err, stats) => {
+ webpack(productionConfig, (err, stats) => {
if (err) {
ringBell();
throw new gutil.PluginError('webpack:build', err);
},
module: {
loaders: [{
- test: /\.jsx?$/,
+ test: /\.js$/,
loaders: ['react-hot', 'babel'],
include: path.join(__dirname, 'src')
}, {
- test: /\.css$/, loader: 'style-loader!css-loader',
+ test: /\.css$/,
+ loader: 'style-loader!css-loader',
}],
}
};
--- /dev/null
+/**
+ * Copyright 2015-present Greg Hurrell. All rights reserved.
+ * Licensed under the terms of the MIT license.
+ */
+
+'use strict';
+
+var path = require('path');
+var webpack = require('webpack');
+
+module.exports = {
+ entry: './src/index',
+ output: {
+ path: path.join(__dirname, 'dist'),
+ filename: 'bundle.js',
+ },
+ plugins: [
+ new webpack.DefinePlugin({
+ 'process.env': {
+ NODE_ENV: JSON.stringify('production'),
+ },
+ }),
+ new webpack.optimize.DedupePlugin(),
+ new webpack.optimize.UglifyJsPlugin()
+ ],
+ module: {
+ loaders: [{
+ test: /\.js$/,
+ loaders: ['babel'],
+ include: path.join(__dirname, 'src')
+ }, {
+ test: /\.css$/,
+ loader: 'style-loader!css-loader',
+ include: path.join(__dirname, 'src')
+ }],
+ }
+};