2020-05-23 17:13:45 +00:00
|
|
|
//
|
2020-06-23 14:19:01 +00:00
|
|
|
// Copyright 2019 DXOS.org
|
2020-05-23 17:13:45 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
const Dotenv = require('dotenv-webpack');
|
|
|
|
const webpack = require('webpack');
|
2020-05-27 23:09:20 +00:00
|
|
|
const HtmlWebPackPlugin = require('html-webpack-plugin');
|
2020-05-23 17:13:45 +00:00
|
|
|
|
|
|
|
const PUBLIC_URL = process.env.PUBLIC_URL || '';
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
devtool: 'eval-source-map',
|
|
|
|
|
|
|
|
devServer: {
|
|
|
|
contentBase: path.join(__dirname, 'dist'),
|
|
|
|
compress: true,
|
|
|
|
disableHostCheck: true,
|
|
|
|
port: 8080,
|
|
|
|
watchOptions: {
|
|
|
|
ignored: /node_modules/,
|
|
|
|
aggregateTimeout: 600
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
node: {
|
|
|
|
fs: 'empty'
|
|
|
|
},
|
|
|
|
|
2020-05-27 23:09:20 +00:00
|
|
|
entry: './src/client/main.js',
|
|
|
|
|
2020-05-23 17:13:45 +00:00
|
|
|
output: {
|
2020-05-27 23:09:20 +00:00
|
|
|
path: `${__dirname}/dist/client`,
|
2020-05-23 17:13:45 +00:00
|
|
|
filename: '[name].bundle.js',
|
|
|
|
publicPath: PUBLIC_URL
|
|
|
|
},
|
|
|
|
|
|
|
|
optimization: {
|
|
|
|
runtimeChunk: 'single',
|
|
|
|
splitChunks: {
|
|
|
|
chunks: 'all',
|
|
|
|
maxInitialRequests: Infinity,
|
|
|
|
minSize: 0,
|
|
|
|
cacheGroups: {
|
|
|
|
vendor: {
|
|
|
|
test: /[\\/]node_modules[\\/]/,
|
2020-05-23 23:01:17 +00:00
|
|
|
name (module) {
|
2020-05-23 17:13:45 +00:00
|
|
|
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
|
|
|
|
|
|
|
|
if (packageName.startsWith('@dxos')) {
|
|
|
|
return 'dxos';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (packageName.startsWith('@material-ui')) {
|
|
|
|
return 'material-ui';
|
|
|
|
}
|
|
|
|
|
|
|
|
return 'vendor';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
2020-05-27 23:09:20 +00:00
|
|
|
// https://github.com/jantimon/html-webpack-plugin#options
|
|
|
|
new HtmlWebPackPlugin({
|
|
|
|
template: './public/index.html',
|
|
|
|
templateParameters: {
|
2020-10-30 19:15:01 +00:00
|
|
|
title: 'Console'
|
2020-05-27 23:09:20 +00:00
|
|
|
}
|
|
|
|
}),
|
2020-05-23 17:13:45 +00:00
|
|
|
|
|
|
|
// https://www.npmjs.com/package/dotenv-webpack#properties
|
|
|
|
new Dotenv({
|
|
|
|
path: process.env.DOT_ENV || '.env'
|
|
|
|
}),
|
|
|
|
|
|
|
|
// NOTE: Must be defined below Dotenv (otherwise will override).
|
|
|
|
// https://webpack.js.org/plugins/environment-plugin
|
2020-05-27 23:09:20 +00:00
|
|
|
new webpack.EnvironmentPlugin({})
|
2020-05-23 17:13:45 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /(node_modules)/,
|
|
|
|
use: {
|
|
|
|
loader: 'babel-loader'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-24 02:37:52 +00:00
|
|
|
// https://github.com/eemeli/yaml-loader
|
|
|
|
{
|
|
|
|
test: /\.ya?ml$/,
|
|
|
|
type: 'json',
|
|
|
|
use: 'yaml-loader'
|
2020-05-23 17:13:45 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@material-ui/styles': path.resolve(__dirname, '..', '..', 'node_modules/@material-ui/styles'),
|
|
|
|
'react': path.resolve(__dirname, '..', '..', 'node_modules/react'),
|
|
|
|
'react-dom': path.resolve(__dirname, '..', '..', 'node_modules/react-dom')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|