Nettoyage de la configuration Webpack

pull/206/head
Mael 2018-03-01 19:39:36 +01:00 committed by Laurent Bossavit
parent 92db4c71af
commit e1279b2b98
5 changed files with 52 additions and 45 deletions

View File

@ -10,10 +10,7 @@
"engines": {
"node": ">=6.2.0 <10.0.0"
},
"browserslist": [
"> 1% in FR",
"not ie < 11"
],
"browserslist": ["> 1% in FR", "not ie < 11"],
"dependencies": {
"@babel/polyfill": "^7.0.0-beta.34",
"classnames": "^2.2.5",
@ -105,7 +102,7 @@
"scripts": {
"start": "node source/server.js",
"externalize": "node source/externalize.js",
"compile": "NODE_ENV='production' webpack --config source/webpack.config.js",
"compile": "NODE_ENV='production' webpack --config source/webpack.prod.js",
"test": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\"",
"test-watch": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js \"test/**/*.test.js\" --watch",
"test-meca": "mocha-webpack --webpack-config source/webpack.test.config.js --require source-map-support/register --require test/helpers/browser.js test/mecanisms.test.js --watch",

View File

@ -1,6 +1,6 @@
var webpack = require('webpack')
var WebpackDevServer = require('webpack-dev-server')
var config = require('./webpack.config')
var config = require('./webpack.dev')
const PORT = process.env.PORT || 3000

View File

@ -1,29 +1,5 @@
var webpack = require('webpack'),
path = require('path'),
prodEnv = process.env.NODE_ENV == 'production', // eslint-disable-line no-undef
HardSourceWebpackPlugin = require('hard-source-webpack-plugin')
var path = require('path')
module.exports = {
devtool: 'cheap-module-source-map',
entry: {
bundle: prodEnv
? ['@babel/polyfill', 'whatwg-fetch', './source/entry.js']
: [
'webpack-dev-server/client?http://0.0.0.0:3000/',
'webpack/hot/only-dev-server',
'@babel/polyfill',
'react-hot-loader/patch',
'./source/entry.js'
],
// le nom "simulateur" est là pour des raisons historiques
simulateur: './source/iframe-script.js',
'colour-chooser': ['@babel/polyfill', './source/entry-colour-chooser.js']
},
output: {
path: path.resolve('./dist/'),
filename: '[name].js',
publicPath: '/dist/'
},
resolve: {
alias: {
Engine: path.resolve('source/engine/'),
@ -32,6 +8,11 @@ module.exports = {
Images: path.resolve('source/images/')
}
},
output: {
path: path.resolve('./dist/'),
filename: '[name].js',
publicPath: '/dist/'
},
module: {
loaders: [
{
@ -88,18 +69,5 @@ module.exports = {
loader: 'babel-loader!nearley-loader'
}
]
},
plugins: [
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
new webpack.NoEmitOnErrorsPlugin()
]
.concat(
!prodEnv
? [
new webpack.HotModuleReplacementPlugin(),
new HardSourceWebpackPlugin()
]
: []
)
.concat(prodEnv ? [new webpack.optimize.UglifyJsPlugin()] : [])
}
}

28
source/webpack.dev.js Normal file
View File

@ -0,0 +1,28 @@
var webpack = require('webpack'),
path = require('path'),
HardSourceWebpackPlugin = require('hard-source-webpack-plugin'),
common = require('./webpack.common.js')
module.exports = {
...common,
entry: {
bundle: [
'webpack-dev-server/client?http://0.0.0.0:3000/',
'webpack/hot/only-dev-server',
'@babel/polyfill',
'react-hot-loader/patch',
'./source/entry.js'
]
// entrées désactivées pour accélérer la compilation au dev
//
// le nom "simulateur" est là pour des raisons historiques
//
// simulateur: './source/iframe-script.js',
// 'colour-chooser': ['@babel/polyfill', './source/entry-colour-chooser.js']
},
plugins: [
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
new webpack.HotModuleReplacementPlugin(),
new HardSourceWebpackPlugin()
]
}

14
source/webpack.prod.js Normal file
View File

@ -0,0 +1,14 @@
var webpack = require('webpack'),
common = require('./webpack.common.js')
module.exports = {
...common,
entry: {
bundle: ['@babel/polyfill', 'whatwg-fetch', './source/entry.js'],
// le nom "simulateur" est là pour des raisons historiques
//
simulateur: './source/iframe-script.js',
'colour-chooser': ['@babel/polyfill', './source/entry-colour-chooser.js']
},
plugins: [new webpack.optimize.UglifyJsPlugin()]
}