Skip to content

Commit

Permalink
Migrated to webpack 4 (hql287#264)
Browse files Browse the repository at this point in the history
* Upgraded dependencies

* Removed unused webpack plugin

* Upgraded to Webpack 4

* Removed CommonsChunkPlugin as webpack 4 handled this automatically

* Removed vendor.js file

* FIxed lint error

Wrap body of for in loop inside an if statement.
More Info: https://eslint.org/docs/rules/guard-for-in
  • Loading branch information
hql287 authored Mar 13, 2018
1 parent c6b4aab commit 8fc84a2
Show file tree
Hide file tree
Showing 9 changed files with 2,146 additions and 1,262 deletions.
18 changes: 11 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,17 @@ function setInitialValues() {
// Changing anything deeper would need to be done with migration
for (const key in defaultOptions) {
// Add level 1 key if not exist
if (!appConfig.has(`${key}`)) {
appConfig.set(`${key}`, defaultOptions[key]);
}
// Add level 2 key if not exist
for (const childKey in defaultOptions[key]) {
if (!appConfig.has(`${key}.${childKey}`)) {
appConfig.set(`${key}.${childKey}`, defaultOptions[key][childKey]);
if (Object.prototype.hasOwnProperty.call(defaultOptions, key)) {
if (!appConfig.has(`${key}`)) {
appConfig.set(`${key}`, defaultOptions[key]);
}
// Add level 2 key if not exist
for (const childKey in defaultOptions[key]) {
if (Object.prototype.hasOwnProperty.call(defaultOptions[key], childKey)) {
if (!appConfig.has(`${key}.${childKey}`)) {
appConfig.set(`${key}.${childKey}`, defaultOptions[key][childKey]);
}
}
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions app/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
Expand All @@ -21,12 +21,10 @@
const isDev = require('electron-is-dev');
if (isDev) {
scripts.push(
'http://localhost:3000/vendor.dev.js',
'http://localhost:3000/main.dev.js'
);
} else {
scripts.push(
'../prod/vendor.prod.js',
'../prod/main.prod.js'
);
}
Expand Down
2 changes: 0 additions & 2 deletions modal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
const isDev = require('electron-is-dev');
if (isDev) {
scripts.push(
'http://localhost:3000/vendor.dev.js',
'http://localhost:3000/modal.dev.js'
);
} else {
scripts.push(
'../prod/vendor.prod.js',
'../prod/modal.prod.js'
);
}
Expand Down
72 changes: 36 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"main": "app.js",
"scripts": {
"start": "electron .",
"dev": "webpack-dev-server",
"build": "webpack --env.production",
"dev": "webpack-dev-server --mode development",
"build": "webpack --env.production --mode production",
"test": "jest",
"test:watch": "jest --watch",
"dist:linux": "electron-builder --linux",
Expand All @@ -28,15 +28,15 @@
"lint-staged": "lint-staged"
},
"dependencies": {
"dotenv": "^4.0.0",
"dotenv": "^5.0.1",
"electron-is-dev": "^0.3.0",
"electron-settings": "^3.1.2",
"electron-updater": "^2.18.2",
"electron-updater": "^2.21.0",
"glob": "^7.1.2",
"i18next": "^10.3.0",
"is-svg": "^2.1.0",
"i18next": "^10.5.0",
"is-svg": "^3.0.0",
"jimp": "^0.2.28",
"moment": "^2.20.1",
"moment": "^2.21.0",
"pouchdb-browser": "6.2.0",
"rc-progress": "^2.2.5",
"react": "^16.2.0",
Expand All @@ -47,57 +47,57 @@
"react-dnd": "^2.5.3",
"react-dnd-html5-backend": "^2.5.3",
"react-dom": "^16.2.0",
"react-i18next": "^7.3.1",
"react-i18next": "^7.5.0",
"react-motion": "^0.5.1",
"react-redux": "^5.0.6",
"react-redux": "^5.0.7",
"recompose": "^0.26.0",
"redux": "^3.7.2",
"redux-actions": "^2.2.1",
"redux-actions": "^2.3.0",
"reselect": "^3.0.1",
"styled-components": "^2.4.0",
"uuid": "^3.1.0"
"styled-components": "^3.2.1",
"uuid": "^3.2.1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-jest": "^22.0.4",
"babel-loader": "^7.1.2",
"babel-minify-webpack-plugin": "^0.2.0",
"babel-plugin-styled-components": "^1.4.0",
"babel-jest": "^22.4.1",
"babel-loader": "^7.1.4",
"babel-minify-webpack-plugin": "^0.3.0",
"babel-plugin-styled-components": "^1.5.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"chai": "^4.1.2",
"clean-webpack-plugin": "^0.1.17",
"compression-webpack-plugin": "^1.1.3",
"clean-webpack-plugin": "^0.1.19",
"compression-webpack-plugin": "^1.1.11",
"devtron": "^1.4.0",
"duplicate-package-checker-webpack-plugin": "^1.2.6",
"electron": "^1.7.10",
"electron-builder": "^19.52.1",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"electron": "^1.8.3",
"electron-builder": "^20.4.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^4.15.0",
"eslint": "^4.18.2",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jest": "^21.5.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jest": "^21.13.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-prettier": "^2.4.0",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-react": "^7.7.0",
"faker": "^4.1.0",
"jest": "^22.0.4",
"jest-styled-components": "^4.6.0",
"lint-staged": "^6.0.0",
"jest": "^22.4.2",
"jest-styled-components": "^5.0.0",
"lint-staged": "^7.0.0",
"pre-commit": "^1.2.2",
"prettier": "^1.9.2",
"react-hot-loader": "^3.0.0-beta.7",
"prettier": "^1.11.1",
"react-hot-loader": "^4.0.0",
"react-test-renderer": "^16.2.0",
"redux-logger": "^3.0.6",
"webpack": "^3.10.0",
"webpack-bundle-analyzer": "^2.9.2",
"webpack-dashboard": "^1.0.0",
"webpack-dev-server": "^2.10.0",
"webpack-merge": "^4.1.0",
"webpack": "^4.1.1",
"webpack-bundle-analyzer": "^2.11.1",
"webpack-cli": "^2.0.11",
"webpack-dev-server": "^3.1.1",
"webpack-merge": "^4.1.2",
"webpack-node-externals": "^1.6.0"
},
"pre-commit": [
Expand Down
2 changes: 0 additions & 2 deletions preview/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
const isDev = require('electron-is-dev');
if (isDev) {
scripts.push(
'http://localhost:3000/vendor.dev.js',
'http://localhost:3000/preview.dev.js'
);
} else {
scripts.push(
'../prod/vendor.prod.js',
'../prod/preview.prod.js'
);
}
Expand Down
2 changes: 0 additions & 2 deletions tour/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
const isDev = require('electron-is-dev');
if (isDev) {
scripts.push(
'http://localhost:3000/vendor.dev.js',
'http://localhost:3000/tour.dev.js'
);
} else {
scripts.push(
'../prod/vendor.prod.js',
'../prod/tour.prod.js'
);
}
Expand Down
10 changes: 0 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,6 @@ const commonConfig = merge([
}),
// Separate source map from bundles
parts.generateSourceMaps({ type: 'none' }),
// Extract Bundle & Code Spliting
parts.extractBundles([
{
name: 'vendor',
minChunks: ({ resource }) =>
resource &&
resource.indexOf('node_modules') >= 0 &&
resource.match(/\.js$/),
},
]),
{
target: 'electron-renderer',
// Set Performance Budget
Expand Down
13 changes: 0 additions & 13 deletions webpack.parts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const webpack = require('webpack');
const BabelWebpackPlugin = require('babel-minify-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const DashboardPlugin = require('webpack-dashboard/plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');

Expand Down Expand Up @@ -40,15 +39,3 @@ exports.minifyJavaScript = () => ({
exports.analyzeBundle = () => ({
plugins: [new BundleAnalyzerPlugin()],
});

// Webpack Dashboard
exports.webpackDashboard = () => ({
plugins: [new DashboardPlugin()],
});

// Extract vendor files
exports.extractBundles = bundles => ({
plugins: bundles.map(
bundle => new webpack.optimize.CommonsChunkPlugin(bundle)
),
});
Loading

0 comments on commit 8fc84a2

Please sign in to comment.