mon-entreprise/source/webpack.config.js

104 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-06-29 10:27:04 +00:00
var webpack = require('webpack'),
path = require('path'),
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']
: [
'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'
]
// 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: {
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/'
},
resolve: {
alias: {
Engine: path.resolve('source/engine/'),
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/')
}
},
2016-06-29 10:27:04 +00:00
module: {
loaders: [
{
test: /\.css$/,
use: [
{
loader: 'style-loader'
},
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1
}
},
{
loader: 'postcss-loader'
2017-03-14 14:00:54 +00:00
}
]
},
{
test: /\.html$/,
loader: 'html-loader'
},
{
test: /\.(jpe?g|png|svg)$/,
use: {
loader: 'file-loader',
options: {
name: 'images/[name].[ext]'
}
}
},
{
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
}
},
{
test: /\.ne$/,
loader: 'babel-loader!nearley-loader'
}
]
2016-06-29 10:27:04 +00:00
},
plugins: [
new webpack.EnvironmentPlugin({ NODE_ENV: 'development' }),
new webpack.NoEmitOnErrorsPlugin()
2016-06-29 10:27:04 +00:00
]
.concat(
!prodEnv
? [
new webpack.HotModuleReplacementPlugin(),
new HardSourceWebpackPlugin()
]
: []
)
.concat(prodEnv ? [new webpack.optimize.UglifyJsPlugin()] : [])
2016-06-29 10:27:04 +00:00
}