Skip to content

Commit

Permalink
Merge pull request #376 from betagouv/webpack-dev-server
Browse files Browse the repository at this point in the history
Retour à webpack-dev-server
  • Loading branch information
laem authored Sep 26, 2018
2 parents 91f51ce + 9a96249 commit 60f7c9d
Show file tree
Hide file tree
Showing 4 changed files with 1,137 additions and 1,548 deletions.
56 changes: 28 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@
"focus-trap-react": "^3.1.2",
"fuse.js": "^3.2.1",
"i18next": "^10.0.7",
"iframe-resizer": "^3.6.1",
"iframe-resizer": "^3.6.2",
"marked": "^0.3.17",
"nearley": "^2.13.0",
"ramda": "^0.25.0",
"raven-for-redux": "^1.3.1",
"raven-js": "^3.26.4",
"rc-progress": "^2.2.5",
"react": "^16.3.1",
"rc-progress": "^2.2.6",
"react": "^16.5.2",
"react-addons-css-transition-group": "^15.6.2",
"react-color": "^2.14.0",
"react-dom": "^16.3.1",
"react-dom": "^16.5.2",
"react-easy-emoji": "^1.2.0",
"react-helmet": "^5.2.0",
"react-highlight-words": "^0.11.0",
"react-hot-loader": "^4.3.5",
"react-i18next": "^7.5.0",
"react-hot-loader": "^4.3.11",
"react-i18next": "^7.13.0",
"react-redux": "^5.0.7",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-select": "^1.2.1",
"react-select-fast-filter-options": "^0.2.3",
"react-spring": "^5.3.18",
"react-spring": "^5.8.0",
"react-transition-group": "^2.2.1",
"react-virtualized": "^9.20.0",
"react-virtualized-select": "^3.1.3",
Expand All @@ -61,7 +61,7 @@
"prepare": "flow-typed update-cache",
"serve:infrance": "cp dist/infrance.html dist/index.html && serve -s dist",
"pretest": "LIST=`git diff --name-only --diff-filter=AMR HEAD^..HEAD | grep .*\\.js | grep -v json`; if [ \"$LIST\" ]; then eslint $LIST; fi && flow check",
"start": "webpack-serve ./source/webpack.dev.js",
"start": "node source/server.js",
"test-inversions": "yarn test-watch --grep 'inversions'",
"test-meca": "yarn test-watch --grep 'Mécanismes'",
"test-rules": "yarn test-watch --grep 'notre base de règles'",
Expand All @@ -71,19 +71,19 @@
"test-components": "mocha-webpack --webpack-config source/webpack.test.js --require source-map-support/register --include componentTestSetup.js --require mock-local-storage ---require test/helpers/browser.js \"source/components/**/*.test.js\" --watch"
},
"devDependencies": {
"@babel/core": "=7.0.0-beta.51",
"@babel/plugin-proposal-decorators": "=7.0.0-beta.51",
"@babel/plugin-proposal-object-rest-spread": "=7.0.0-beta.51",
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-syntax-decorators": "=7.0.0-beta.51",
"@babel/polyfill": "=7.0.0-beta.51",
"@babel/preset-env": "=7.0.0-beta.51",
"@babel/plugin-syntax-decorators": "^7.1.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/preset-flow": "^7.0.0-beta.51",
"@babel/preset-react": "=7.0.0-beta.51",
"@babel/preset-react": "^7.0.0",
"akh": "^3.1.2",
"autoprefixer": "^8.6.3",
"babel-eslint": "^8.2.5",
"babel-loader": "8.0.0-beta.2",
"babel-eslint": "^9.0.0",
"babel-loader": "^8.0.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators": "^6.24.1",
Expand All @@ -96,14 +96,15 @@
"css-loader": "^0.28.11",
"csv-loader": "^2.1.1",
"cypress": "^3.1.0",
"daggy": "^1.2.0",
"daggy": "^1.3.0",
"dedent-js": "^1.0.1",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^5.5.0",
"eslint-config-prettier": "^3.0.1",
"eslint-plugin-flowtype": "^2.46.3",
"eslint": "^5.6.0",
"eslint-config-prettier": "^3.1.0",
"eslint-plugin-flowtype": "^2.50.1",
"eslint-plugin-react": "^7.11.1",
"express": "^4.16.3",
"file-loader": "^1.1.11",
"flow-bin": "^0.72.0",
"flow-typed": "^2.4.0",
Expand All @@ -123,19 +124,18 @@
"nearley-loader": "^2.0.0",
"postcss-loader": "^2.1.2",
"ramda-fantasy": "^0.8.0",
"serve": "^10.0.0",
"serve": "^10.0.2",
"sinon": "^4.5.0",
"sinon-chai": "^3.0.0",
"source-map-support": "^0.5.4",
"style-loader": "^0.20.3",
"url-loader": "^1.0.1",
"webpack": "^4.17.1",
"webpack-cli": "^3.0.8",
"webpack": "^4.20.1",
"webpack-cli": "^3.1.1",
"webpack-dev-middleware": "^3.4.0",
"webpack-hot-middleware": "^2.24.2",
"webpack-pwa-manifest": "^3.6.2",
"webpack-serve": "^2.0.2",
"webpack-serve-overlay": "^0.2.2",
"webpack-serve-waitpage": "^1.0.2",
"workbox-webpack-plugin": "^3.3.1",
"workbox-webpack-plugin": "^3.6.1",
"yaml-loader": "^0.5.0"
}
}
38 changes: 38 additions & 0 deletions source/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const express = require('express')
const webpack = require('webpack')
const webpackDevMiddleware = require('webpack-dev-middleware')

const app = express()
const config = require('./webpack.dev.js')
const compiler = webpack(config)
const history = require('connect-history-api-fallback')

app.use(
history({
rewrites: [
{
from: /^\/embauche\/.*$|^\/embauche$/,
to: '/embauche.html'
},
{
from: /^\/infrance\/.*$|^\/infrance$/,
to: '/infrance.html'
}
]
})
)

// Tell express to use the webpack-dev-middleware and use the webpack.config.js
// configuration file as a base.
app.use(
webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
hot: true
})
)

app.use(require('webpack-hot-middleware')(compiler))

app.listen(8080, function() {
console.log('Example app listening on port 8080!\n')
})
39 changes: 3 additions & 36 deletions source/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,14 @@
const { map, concat } = require('ramda')
const webpack = require('webpack')
const common = require('./webpack.common.js')
const webpackServeWaitpage = require('webpack-serve-waitpage')
const history = require('connect-history-api-fallback')
const convert = require('koa-connect')

module.exports = {
...common,
mode: 'development',
entry: map(concat(['react-hot-loader/patch']), common.entry),
serve: {
host: '0.0.0.0',
hotClient: {
allEntries: true,
host: { client: '*', server: '0.0.0.0' }
},
add: (app, middleware, options) => {
app.use(
convert(
history({
rewrites: [
{
from: /^\/embauche\/.*$|^\/embauche$/,
to: '/embauche.html'
},
{
from: /^\/infrance\/.*$|^\/infrance$/,
to: '/infrance.html'
}
]
})
)
)

app.use(
webpackServeWaitpage(options, {
theme: 'material'
})
)
}
},
entry: map(concat(['webpack-hot-middleware/client']), common.entry),
plugins: [
...common.plugins,
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' })
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
new webpack.HotModuleReplacementPlugin()
]
}
Loading

0 comments on commit 60f7c9d

Please sign in to comment.