Skip to content

Commit fd6ca22

Browse files
greenkeeper[bot]bbmoz
authored andcommitted
Update webpack to the latest version 🚀and update how E2E tests are run (#179)
* fix(package): update webpack to version 4.0.0 * chore: auto set node version * chore: update project deps for new webpack * chore: update e2e testing premise * chore: disable e2e tests on CI
1 parent e4c661f commit fd6ca22

File tree

8 files changed

+1476
-624
lines changed

8 files changed

+1476
-624
lines changed

‎.envrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
export PATH=$PATH:$(pwd)/node_modules/.bin/:$(pwd)/bin/
1+
nvmrc=~/.nvm/nvm.sh
2+
if [ -e $nvmrc ]; then
3+
source $nvmrc
4+
nvm use
5+
fi
6+
7+
PATH_add node_modules/.bin
28

39
[ -f .env ] && source .env

‎.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ script:
3030
- yarn install
3131
- yarn test
3232
- mongo --eval "db.getSiblingDB('admin').shutdownServer()"
33-
- NODE_ENV=ci yarn e2e
33+
# - yarn e2e -e ci --tag smoke
3434

3535
after_script: greenkeeper-lockfile-upload
3636

‎client/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { connect } from 'react-redux'
33
import { Route, Switch } from 'react-router-dom'
44
import PropTypes from 'prop-types'
55
import Loadable from 'react-loadable'
6-
76
import Loading from './components/Loading/Loading'
87
import AuthActionCreator from './actions/auth'
98
import ForgotPasswordForm from './components/ForgotPasswordForm/ForgotPasswordForm'

‎e2e/pree2e.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# set up selenium server
4+
pkill -f selenium-standalone
5+
./node_modules/.bin/selenium-standalone install
6+
37
set -ex
48

5-
# make sure app is running
9+
# run selenium server
10+
./node_modules/.bin/selenium-standalone start &
11+
12+
# run app
613
FILE=e2e.log
714
rm -f $FILE
815
touch $FILE

‎nightwatch.conf.js

Lines changed: 32 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
const seleniumServer = require('selenium-server')
2-
const phantomjs = require('phantomjs-prebuilt')
3-
const chromedriver = require('chromedriver')
4-
const geckodriver = require('geckodriver')
5-
61
require('nightwatch-cucumber')({
72
nightwatchOutput: false,
83
cucumberArgs: [
@@ -21,68 +16,49 @@ const config = {
2116
live_output: false,
2217
disable_colors: false,
2318
selenium: {
24-
start_process: true,
25-
server_path: seleniumServer.path,
26-
log_path: '',
27-
host: '127.0.0.1',
28-
port: 4444
19+
start_process: false
2920
},
3021
test_settings: {
31-
chrome: {
22+
default: {
23+
launch_url: 'http://localhost',
24+
selenium_port: 4444,
25+
selenium_host: 'localhost',
3226
desiredCapabilities: {
3327
browserName: 'chrome',
3428
javascriptEnabled: true,
35-
acceptSslCerts: true
36-
},
37-
selenium: {
38-
cli_args: {
39-
'webdriver.chrome.driver': chromedriver.path
29+
acceptSslCerts: true,
30+
chromeOptions: {
31+
args: [
32+
'window-size=1280,800',
33+
'disable-web-security'
34+
]
35+
},
36+
selenium: {
37+
cli_args: {
38+
'webdriver.chrome.driver': 'node_modules/.bin/chromedriver'
39+
}
4040
}
41-
}
42-
},
43-
firefox: {
44-
desiredCapabilities: {
45-
browserName: 'firefox',
46-
javascriptEnabled: true,
47-
acceptSslCerts: true
4841
},
49-
selenium: {
50-
cli_args: {
51-
'webdriver.gecko.driver': geckodriver.path
42+
ci: {
43+
launch_url: 'http://localhost',
44+
selenium_port: 4444,
45+
selenium_host: 'localhost',
46+
desiredCapabilities: {
47+
browserName: 'chrome',
48+
javascriptEnabled: true,
49+
acceptSslCerts: true,
50+
chromeOptions: {
51+
args: [
52+
'headless',
53+
'disable-web-security',
54+
'ignore-certificate-errors',
55+
'disable-gpu'
56+
]
57+
}
5258
}
5359
}
5460
}
5561
}
5662
}
5763

58-
if (process.env.NODE_ENV === 'ci') {
59-
config.test_settings.default = {
60-
desiredCapabilities: {
61-
browserName: 'chrome',
62-
javascriptEnabled: true,
63-
acceptSslCerts: true,
64-
chromeOptions: {
65-
args: [
66-
'headless',
67-
'disable-web-security',
68-
'ignore-certificate-errors',
69-
'disable-gpu'
70-
]
71-
}
72-
}
73-
}
74-
} else {
75-
config.test_settings.default = {
76-
launch_url: 'http://localhost:8087',
77-
selenium_port: 4444,
78-
selenium_host: '127.0.0.1',
79-
desiredCapabilities: {
80-
browserName: 'phantomjs',
81-
javascriptEnabled: true,
82-
acceptSslCerts: true,
83-
'phantomjs.binary.path': phantomjs.path
84-
}
85-
}
86-
}
87-
8864
module.exports = config

‎package.json

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"node": "9.2.0"
1111
},
1212
"scripts": {
13-
"client:watch": "webpack --watch --hide-modules",
13+
"client:watch": "webpack --mode development --watch --progress --hide-modules",
1414
"server:watch": "nodemon --watch server/ --ignore server/public/ --exec 'node server/'",
1515
"sync": "browser-sync start --proxy localhost:3000 --files server/**/* --port 3001 --ws --no-open --https",
1616
"prestart": "yarn db start && yarn email start && yarn clear-ports",
@@ -22,7 +22,7 @@
2222
"pree2e": "./e2e/pree2e.sh",
2323
"e2e": "nightwatch",
2424
"lint": "eslint --ignore-pattern server/public/ client/ server/",
25-
"build": "webpack --bail --display errors-only",
25+
"build": "webpack --mode production --bail --display errors-only",
2626
"db": "./.setup/db/run.sh",
2727
"email": "./.setup/email/run.sh",
2828
"clear-ports": "./.setup/client/clear-ports.sh"
@@ -40,13 +40,14 @@
4040
"babel-register": "^6.26.0",
4141
"bcryptjs": "^2.4.3",
4242
"body-parser": "^1.18.2",
43-
"copy-webpack-plugin": "^4.3.1",
43+
"clean-webpack-plugin": "^0.1.19",
44+
"copy-webpack-plugin": "^4.5.1",
4445
"css-loader": "^0.28.7",
4546
"express": "^4.16.1",
4647
"express-jwt": "^5.3.0",
4748
"express-promise-router": "^3.0.1",
48-
"extract-text-webpack-plugin": "^3.0.1",
49-
"hard-source-webpack-plugin": "^0.6.0",
49+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
50+
"file-loader": "^1.1.6",
5051
"history": "^4.7.2",
5152
"html-webpack-plugin": "^3.0.0",
5253
"jsonwebtoken": "^8.1.0",
@@ -73,33 +74,31 @@
7374
"sendmail": "^1.2.0",
7475
"style-loader": "^0.20.0",
7576
"url-loader": "^1.0.0",
76-
"webpack": "^3.6.0",
77+
"webpack": "^4.0.0",
7778
"webpack-bundle-analyzer": "^2.9.2",
78-
"webpack-visualizer-plugin": "^0.1.11",
79-
"file-loader": "^1.1.6"
79+
"webpack-cli": "^2.0.13",
80+
"webpack-visualizer-plugin": "^0.1.11"
8081
},
8182
"devDependencies": {
8283
"ava": "^0.25.0",
8384
"browser-sync": "^2.23.3",
8485
"chromedriver": "^2.34.1",
8586
"cucumber": "^4.0.0",
8687
"cucumber-pretty": "^1.3.2",
87-
"eslint": "^4.8.0",
88+
"eslint": "^4.19.1",
8889
"eslint-config-standard": "^11.0.0",
89-
"eslint-plugin-import": "^2.7.0",
90-
"eslint-plugin-node": "^6.0.0",
91-
"eslint-plugin-promise": "^3.5.0",
92-
"eslint-plugin-react": "^7.4.0",
90+
"eslint-plugin-import": "^2.9.0",
91+
"eslint-plugin-node": "^6.0.1",
92+
"eslint-plugin-promise": "^3.7.0",
93+
"eslint-plugin-react": "^7.7.0",
9394
"eslint-plugin-standard": "^3.0.1",
94-
"geckodriver": "^1.10.0",
9595
"ignore-styles": "^5.0.1",
9696
"mongodb-memory-server": "^1.6.3",
9797
"nightwatch": "^0.9.19",
9898
"nightwatch-cucumber": "^9.0.0",
9999
"nodemon": "^1.12.1",
100100
"npm-run-all": "^4.1.1",
101-
"phantomjs-prebuilt": "^2.1.16",
102-
"selenium-server": "^3.8.1",
101+
"selenium-standalone": "^6.13.0",
103102
"sinon": "^5.0.0",
104103
"supertest": "^3.0.0"
105104
},

‎webpack.config.js

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const webpack = require('webpack')
33
const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const ExtractTextPlugin = require('extract-text-webpack-plugin')
55
const CopyPlugin = require('copy-webpack-plugin')
6-
const HardSourcePlugin = require('hard-source-webpack-plugin')
7-
// allow us to visualise our bundles and optimise
6+
const CleanPlugin = require('clean-webpack-plugin')
7+
/* allow us to visualise our bundles and optimise
88
const Visualizer = require('webpack-visualizer-plugin')
99
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
10-
//
10+
*/
1111

1212
const env = require('./.setup/client/env')
1313
const clientDir = path.join(__dirname, 'client')
@@ -32,6 +32,17 @@ const config = {
3232
]
3333
},
3434

35+
optimization: {
36+
runtimeChunk: 'single',
37+
splitChunks: {
38+
chunks: 'initial',
39+
cacheGroups: {
40+
default: false,
41+
vendors: false
42+
}
43+
}
44+
},
45+
3546
output: {
3647
path: path.join(__dirname, 'server', 'public'),
3748
publicPath: '/',
@@ -79,12 +90,27 @@ const config = {
7990
},
8091

8192
plugins: [
93+
new CleanPlugin(['server/public/'], {root: __dirname}),
94+
8295
new HtmlWebpackPlugin({
83-
template: path.join(clientDir, 'index.html')
96+
inject: true,
97+
template: path.join(clientDir, 'index.html'),
98+
minify: {
99+
removeComments: true,
100+
collapseWhitespace: true,
101+
removeRedundantAttributes: true,
102+
useShortDoctype: true,
103+
removeEmptyAttributes: true,
104+
removeStyleLinkTypeAttributes: true,
105+
keepClosingSlash: true,
106+
minifyJS: true,
107+
minifyCSS: true,
108+
minifyURLs: true
109+
}
84110
}),
85111

86112
new ExtractTextPlugin({
87-
filename: 'client.css'
113+
filename: '[name].css'
88114
}),
89115

90116
new webpack.DefinePlugin({
@@ -95,20 +121,9 @@ const config = {
95121
{from: path.join(clientDir, 'robots.txt')}
96122
]),
97123

98-
new HardSourcePlugin({
99-
cacheDirectory: path.join('..', '..', 'node_modules', '.cache', 'hard-source', '[confighash]')
100-
}),
101-
102-
new webpack.HashedModuleIdsPlugin(), // ensures vendor bundle hash only changes when it needs to
103-
104-
// CommonsChunkPlugin makes sure we don't have the same modules included in multiple chunks
105-
new webpack.optimize.CommonsChunkPlugin({ // vendor must be included before manifest
106-
name: 'vendor'
107-
}),
124+
// ensures vendor bundle hash only changes when it needs to
125+
new webpack.HashedModuleIdsPlugin() /*,
108126
109-
new webpack.optimize.CommonsChunkPlugin({ // separate the webpack manifest from our main chunk
110-
name: 'manifest'
111-
})/*,
112127
new Visualizer()
113128
*/
114129
/*

0 commit comments

Comments
 (0)