2016-06-29 10:27:04 +00:00
|
|
|
var webpack = require('webpack'),
|
2017-05-10 14:09:36 +00:00
|
|
|
path = require('path'),
|
2018-02-14 15:01:37 +00:00
|
|
|
prodEnv = process.env.NODE_ENV == 'production', // eslint-disable-line no-undef
|
|
|
|
HardSourceWebpackPlugin = require('hard-source-webpack-plugin')
|
2016-06-29 10:27:04 +00:00
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
devtool: 'cheap-module-source-map',
|
2017-12-11 17:21:31 +00:00
|
|
|
entry: {
|
|
|
|
bundle: prodEnv
|
|
|
|
? ['@babel/polyfill', 'whatwg-fetch', './source/entry.js']
|
|
|
|
: [
|
2018-02-12 17:46:16 +00:00
|
|
|
'webpack-dev-server/client?http://0.0.0.0:3000/',
|
2017-12-11 17:21:31 +00:00
|
|
|
'webpack/hot/only-dev-server',
|
|
|
|
'@babel/polyfill',
|
|
|
|
'react-hot-loader/patch',
|
|
|
|
'./source/entry.js'
|
2018-02-19 15:33:51 +00:00
|
|
|
]
|
2018-01-15 20:01:05 +00:00
|
|
|
// le nom "simulateur" est là pour des raisons historiques
|
2017-12-11 17:21:31 +00:00
|
|
|
},
|
2016-06-29 10:27:04 +00:00
|
|
|
output: {
|
2017-05-10 14:09:36 +00:00
|
|
|
path: path.resolve('./dist/'),
|
2017-12-11 17:21:31 +00:00
|
|
|
filename: '[name].js',
|
2016-06-29 10:27:04 +00:00
|
|
|
publicPath: '/dist/'
|
|
|
|
},
|
2017-05-10 14:09:36 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
Engine: path.resolve('source/engine/'),
|
2018-01-19 10:57:45 +00:00
|
|
|
Règles: path.resolve('source/règles/'),
|
2017-12-11 14:42:03 +00:00
|
|
|
Components: path.resolve('source/components/'),
|
|
|
|
Images: path.resolve('source/images/')
|
2017-05-10 14:09:36 +00:00
|
|
|
}
|
|
|
|
},
|
2016-06-29 10:27:04 +00:00
|
|
|
module: {
|
2018-01-03 15:54:19 +00:00
|
|
|
loaders: [
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'style-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
|
|
|
sourceMap: true,
|
|
|
|
importLoaders: 1
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2018-01-19 11:29:43 +00:00
|
|
|
loader: 'postcss-loader'
|
2017-03-14 14:00:54 +00:00
|
|
|
}
|
2018-01-03 15:54:19 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.html$/,
|
|
|
|
loader: 'html-loader'
|
|
|
|
},
|
2018-02-05 17:17:56 +00:00
|
|
|
{
|
|
|
|
test: /\.(jpe?g|png|svg)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: {
|
|
|
|
name: 'images/[name].[ext]'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2018-01-03 15:54:19 +00:00
|
|
|
{
|
|
|
|
test: /\.yaml$/,
|
|
|
|
loader: 'json-loader!yaml-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
loader: 'babel-loader'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.csv$/,
|
|
|
|
loader: 'csv-loader',
|
|
|
|
options: {
|
|
|
|
dynamicTyping: true,
|
|
|
|
header: true,
|
|
|
|
skipEmptyLines: true
|
2017-03-14 14:00:54 +00:00
|
|
|
}
|
2018-01-03 15:54:19 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.ne$/,
|
|
|
|
loader: 'babel-loader!nearley-loader'
|
2017-09-19 14:55:23 +00:00
|
|
|
}
|
2018-01-03 15:54:19 +00:00
|
|
|
]
|
2016-06-29 10:27:04 +00:00
|
|
|
},
|
2017-05-05 17:55:29 +00:00
|
|
|
plugins: [
|
2017-05-07 17:45:44 +00:00
|
|
|
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
|
2017-05-18 14:04:23 +00:00
|
|
|
new webpack.NoEmitOnErrorsPlugin()
|
2016-06-29 10:27:04 +00:00
|
|
|
]
|
2018-02-14 15:01:37 +00:00
|
|
|
.concat(
|
|
|
|
!prodEnv
|
|
|
|
? [
|
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
|
|
|
new HardSourceWebpackPlugin()
|
|
|
|
]
|
|
|
|
: []
|
|
|
|
)
|
2018-01-03 15:54:19 +00:00
|
|
|
.concat(prodEnv ? [new webpack.optimize.UglifyJsPlugin()] : [])
|
2016-06-29 10:27:04 +00:00
|
|
|
}
|