Commit 178c590b authored by Jaden DIEFENBAUGH's avatar Jaden DIEFENBAUGH

updated to webpack 4 & associated pkgs! closes #66

parent 29c5364b
......@@ -6,30 +6,13 @@ import 'bootstrap/dist/css/bootstrap.min.css';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { AppContainer } from 'react-hot-loader';
import App from './src/components/App.jsx';
import store from '@store';
ReactDOM.render(
<AppContainer>
<Provider store={ store }>
<App/>
</Provider>
</AppContainer>,
<Provider store={ store }>
<App/>
</Provider>
,
document.getElementById('root')
);
// Hot Module Replacement API
if (module.hot) {
module.hot.accept('./src/components/App', () => {
const NextApp = require('./src/components/App').default;
ReactDOM.render(
<AppContainer>
<Provider store={ store }>
<NextApp/>
</Provider>
</AppContainer>,
document.getElementById('root')
);
});
}
This diff is collapsed.
......@@ -11,6 +11,7 @@ import {
Route,
Switch,
} from 'react-router-dom';
import { hot } from 'react-hot-loader';
import MainNav from './MainNav.jsx';
import MainContent from './MainContent.jsx';
......@@ -44,4 +45,4 @@ class App extends React.PureComponent<Props, State> {
}
}
export default App;
export default hot(module)(App);
......@@ -2,7 +2,6 @@
const { resolve } = require('path');
var webpack = require('webpack')
const VisualizerPlugin = require('webpack-visualizer-plugin');
const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
......@@ -18,7 +17,8 @@ module.exports = {
'./main.jsx',
]
},
mode: 'development',
devtool: 'inline-source-map',
output: {
// use [name] for sanity checks & debugging
filename: '[name].js',
......@@ -88,8 +88,6 @@ module.exports = {
},
devServer: {
},
// fancy sourcemaps
devtool: 'eval-source-map',
plugins: [
//uses the index.ejs template to generate dynamic html pages based on hashes
new HtmlWebpackPlugin({
......@@ -97,38 +95,10 @@ module.exports = {
template: 'index.html'
}),
// instead of hashes for module names, use names
new webpack.NamedModulesPlugin(),
//new webpack.HashedModuleIdsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'main',
chunks: [ 'main' ],
minChunks: isExternal
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: (module) => !isExternal(module)
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
//scope hoisting
//breaks HMR somehow, don't use it
//new webpack.optimize.ModuleConcatenationPlugin(),
/*******************
* POST-PROCESSING *
*******************/
//always write to disk
new HtmlWebpackHarddiskPlugin(),
//generate a little viz for insight into bundle contents/sizes
new VisualizerPlugin()
......@@ -160,11 +130,8 @@ if(process.env.NODE_ENV === 'test'){
// PROD
// TODO: pull out into different webpack config
if (process.env.NODE_ENV === 'production') {
module.mode = 'production';
module.exports.output.publicPath = './';
// simpler source map alg
module.exports.devtool = 'source-map';
// use [hash] to prevent using stale caches
module.exports.output.filename = '[name]-[hash].js',
module.exports.plugins = [
// make sure the env is the string 'production'
new webpack.DefinePlugin({
......@@ -173,11 +140,5 @@ if (process.env.NODE_ENV === 'production') {
NODE_ENV: '"production"'
}
}),
// minimize
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
}),
new UglifyJsPlugin(),
].concat(module.exports.plugins);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment