2019-03-20 15:28:18 -05:00
|
|
|
const path = require('path');
|
|
|
|
|
2019-11-22 02:14:00 -06:00
|
|
|
const {AvocadoPlugin} = require('@avocado/core/webpack/plugin');
|
2019-03-20 15:28:18 -05:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
2019-04-18 21:39:31 -05:00
|
|
|
const webpack = require('webpack');
|
2019-03-20 15:28:18 -05:00
|
|
|
|
|
|
|
const config = require('./webpack.common.config');
|
2019-09-30 23:38:44 -05:00
|
|
|
const isProduction = !!process.argv.find((arg) => '--production' === arg);
|
2019-03-20 15:28:18 -05:00
|
|
|
|
|
|
|
config.entry = {
|
|
|
|
client: [
|
2019-11-22 02:14:00 -06:00
|
|
|
'@avocado/core/webpack/entry',
|
2019-09-22 21:25:43 -05:00
|
|
|
path.join(__dirname, 'client', 'index.scss'),
|
2019-03-20 22:23:26 -05:00
|
|
|
path.join(__dirname, 'client', 'index.js'),
|
2019-03-20 15:28:18 -05:00
|
|
|
],
|
|
|
|
};
|
2019-09-30 23:38:44 -05:00
|
|
|
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',
|
2019-03-20 15:28:18 -05:00
|
|
|
},
|
2019-09-30 23:38:44 -05:00
|
|
|
host: '0.0.0.0',
|
|
|
|
overlay: true,
|
|
|
|
port: 8421,
|
|
|
|
stats: 'minimal',
|
|
|
|
watchContentBase: true,
|
|
|
|
};
|
|
|
|
config.devtool = 'eval-source-map';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
config.devtool = 'source-map';
|
|
|
|
}
|
2019-05-05 17:03:15 -05:00
|
|
|
// Babel config file.
|
|
|
|
config.module.rules[0].use.options.configFile = path.resolve(
|
|
|
|
__dirname, 'babel.client.config.js'
|
|
|
|
);
|
2019-03-20 15:28:18 -05:00
|
|
|
config.node = {
|
|
|
|
fs: 'empty',
|
|
|
|
path: 'empty',
|
|
|
|
};
|
|
|
|
config.plugins.push(new HtmlWebpackPlugin({
|
|
|
|
template: path.resolve(__dirname, 'client', 'index.html'),
|
|
|
|
}));
|
2019-04-18 21:39:31 -05:00
|
|
|
config.plugins.push(new webpack.ProvidePlugin({
|
|
|
|
THREE: 'three',
|
|
|
|
}));
|
2019-04-22 21:03:16 -05:00
|
|
|
config.plugins.push(new webpack.DefinePlugin({
|
|
|
|
AVOCADO_CLIENT: true,
|
|
|
|
AVOCADO_SERVER: false,
|
|
|
|
}));
|
2019-11-22 02:14:00 -06:00
|
|
|
config.plugins.push(new AvocadoPlugin(__dirname, 'client'));
|
2019-03-20 15:28:18 -05:00
|
|
|
|
|
|
|
module.exports = config;
|