humus-old/webpack.client.config.js
2019-11-22 02:15:36 -06:00

59 lines
1.6 KiB
JavaScript

const path = require('path');
const {AvocadoPlugin} = require('@avocado/core/webpack/plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const config = require('./webpack.common.config');
const isProduction = !!process.argv.find((arg) => '--production' === arg);
config.entry = {
client: [
'@avocado/core/webpack/entry',
path.join(__dirname, 'client', 'index.scss'),
path.join(__dirname, 'client', 'index.js'),
],
};
if (!isProduction) {
config.devServer = {
compress: true,
contentBase: path.resolve(__dirname, 'resource'),
disableHostCheck: true,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
host: '0.0.0.0',
overlay: true,
port: 8421,
stats: 'minimal',
watchContentBase: true,
};
config.devtool = 'eval-source-map';
}
else {
config.devtool = 'source-map';
}
// Babel config file.
config.module.rules[0].use.options.configFile = path.resolve(
__dirname, 'babel.client.config.js'
);
config.node = {
fs: 'empty',
path: 'empty',
};
config.plugins.push(new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'client', 'index.html'),
}));
config.plugins.push(new webpack.ProvidePlugin({
THREE: 'three',
}));
config.plugins.push(new webpack.DefinePlugin({
AVOCADO_CLIENT: true,
AVOCADO_SERVER: false,
}));
config.plugins.push(new AvocadoPlugin(__dirname, 'client'));
module.exports = config;