2018-02-26 20:50:13 +01:00
|
|
|
const webpack = require('webpack');
|
2018-06-15 22:51:42 +02:00
|
|
|
if (process.env.NODE_ENV === 'development') {
|
|
|
|
require('dotenv').config();
|
|
|
|
}
|
2016-05-03 06:09:16 +02:00
|
|
|
|
|
|
|
module.exports = {
|
2018-02-26 20:50:13 +01:00
|
|
|
devtool: 'cheap-module-eval-source-map',
|
|
|
|
entry: {
|
2018-05-03 02:34:03 +02:00
|
|
|
app: [
|
2018-02-26 20:50:13 +01:00
|
|
|
'webpack-hot-middleware/client',
|
2018-05-03 02:34:03 +02:00
|
|
|
'react-hot-loader/patch',
|
2018-02-26 20:50:13 +01:00
|
|
|
'./client/index.jsx',
|
2016-11-09 00:11:12 +01:00
|
|
|
],
|
|
|
|
vendor: [
|
|
|
|
'react',
|
|
|
|
'react-dom'
|
|
|
|
]
|
|
|
|
},
|
2016-05-03 06:09:16 +02:00
|
|
|
output: {
|
2018-05-04 22:36:59 +02:00
|
|
|
path: `${__dirname}`,
|
2018-02-26 20:50:13 +01:00
|
|
|
filename: 'app.js',
|
2018-05-04 22:36:59 +02:00
|
|
|
publicPath: '/'
|
2016-05-03 06:09:16 +02:00
|
|
|
},
|
|
|
|
resolve: {
|
2017-11-06 22:19:43 +01:00
|
|
|
extensions: ['.js', '.jsx'],
|
2016-11-09 00:11:12 +01:00
|
|
|
modules: [
|
|
|
|
'client',
|
2016-11-16 19:12:36 +01:00
|
|
|
'node_modules'
|
2016-11-09 00:11:12 +01:00
|
|
|
]
|
2016-05-03 06:09:16 +02:00
|
|
|
},
|
2018-02-26 20:50:13 +01:00
|
|
|
plugins: [
|
2016-06-23 00:36:04 +02:00
|
|
|
new webpack.HotModuleReplacementPlugin(),
|
2016-11-09 00:11:12 +01:00
|
|
|
new webpack.optimize.CommonsChunkPlugin({
|
|
|
|
name: 'vendor',
|
|
|
|
minChunks: Infinity,
|
|
|
|
filename: 'vendor.js',
|
|
|
|
}),
|
2016-06-23 00:36:04 +02:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
'process.env': {
|
2018-02-26 20:50:13 +01:00
|
|
|
API_URL: process.env.API_URL ? `"${process.env.API_URL}"` : undefined,
|
2016-06-23 00:36:04 +02:00
|
|
|
CLIENT: JSON.stringify(true),
|
2017-03-30 18:36:26 +02:00
|
|
|
FORCE_TO_HTTPS: process.env.FORCE_TO_HTTPS === 'true' ?
|
|
|
|
JSON.stringify(true) :
|
|
|
|
JSON.stringify(false),
|
2018-02-26 20:50:13 +01:00
|
|
|
NODE_ENV: JSON.stringify('development'),
|
|
|
|
S3_BUCKET: process.env.S3_BUCKET ? `"${process.env.S3_BUCKET}"` : undefined,
|
|
|
|
S3_BUCKET_URL_BASE: process.env.S3_BUCKET_URL_BASE ? `"${process.env.S3_BUCKET_URL_BASE}"` : undefined,
|
|
|
|
AWS_REGION: process.env.AWS_REGION ? `"${process.env.AWS_REGION}"` : undefined
|
2016-06-23 00:36:04 +02:00
|
|
|
}
|
|
|
|
})
|
2016-05-03 06:09:16 +02:00
|
|
|
],
|
|
|
|
module: {
|
2018-05-03 02:34:03 +02:00
|
|
|
rules: [
|
2016-05-03 06:09:16 +02:00
|
|
|
{
|
2016-06-27 23:40:16 +02:00
|
|
|
test: /\.jsx?$/,
|
2016-05-03 06:09:16 +02:00
|
|
|
exclude: [/node_modules/, /.+\.config.js/],
|
2018-05-03 02:34:03 +02:00
|
|
|
use: [{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
cacheDirectory: true,
|
|
|
|
plugins: ['react-hot-loader/babel'],
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
loader: 'eslint-loader'
|
|
|
|
}]
|
2018-05-09 02:57:16 +02:00
|
|
|
// use: {
|
|
|
|
// loader: 'babel-loader',
|
|
|
|
// options: {
|
|
|
|
// cacheDirectory: true,
|
|
|
|
// plugins: ['react-hot-loader/babel'],
|
|
|
|
// }
|
|
|
|
// }
|
2016-05-03 06:09:16 +02:00
|
|
|
},
|
2016-05-03 22:13:04 +02:00
|
|
|
{
|
2016-05-10 20:18:36 +02:00
|
|
|
test: /\.scss$/,
|
2017-11-06 22:19:43 +01:00
|
|
|
loaders: ['style-loader', 'css-loader', 'sass-loader']
|
2016-05-11 19:19:37 +02:00
|
|
|
},
|
|
|
|
{
|
2016-08-15 17:51:11 +02:00
|
|
|
test: /\.(svg|mp3)$/,
|
2017-11-06 22:19:43 +01:00
|
|
|
loader: 'file-loader'
|
2016-08-18 20:22:47 +02:00
|
|
|
},
|
|
|
|
{
|
2018-02-26 20:50:13 +01:00
|
|
|
test: /fonts\/.*\.(eot|svg|ttf|woff|woff2)$/,
|
|
|
|
loader: 'file-loader'
|
2018-05-15 21:10:24 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /.*loop-protect.min.js$/,
|
|
|
|
loader: 'raw-loader'
|
2016-05-03 22:13:04 +02:00
|
|
|
}
|
2016-05-03 06:09:16 +02:00
|
|
|
],
|
|
|
|
},
|
2016-08-11 19:24:02 +02:00
|
|
|
};
|