const path = require('path'); 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: [ '@babel/polyfill', 'register-packets', 'register-synchronizeds', 'register-traits', '@avocado/behavior/item/initialize', 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.module.rules[1].use.options.paths.push( path.resolve(__dirname, 'client'), ); config.module.rules[2].use.options.paths.push( path.resolve(__dirname, 'client'), ); config.module.rules[3].use.options.paths.push( path.resolve(__dirname, 'client'), ); 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, })); module.exports = config;