feat(phone/webpack): Allow for use of react-devtools in game

This is dynamically added to the bundle depending on the environment. In production, react-devtools will not be bundled. Build a development bundle using `yarn build:dev`
This commit is contained in:
Taso committed 2021-02-08 23:00:33 -05:00
1 parent eaf27f37ef
commit 7b6d49f661
6 files changed
+730 -54

No files matched your search

+18 -33
View File
@@ -1,12 +1,12 @@
const path = require("path");
const webpack = require("webpack");
const path = require('path');
const webpack = require('webpack');
module.exports = (options) => ({
mode: options.mode,
entry: options.entry,
output: {
path: path.resolve(process.cwd(), "../resources/html"),
filename: "[name].js",
path: path.resolve(process.cwd(), '../resources/html'),
filename: '[name].js',
},
module: {
rules: [
@@ -14,7 +14,7 @@ module.exports = (options) => ({
test: /\.tsx?$/,
use: [
{
loader: "ts-loader",
loader: 'ts-loader',
options: {
transpileOnly: true,
},
@@ -26,7 +26,7 @@ module.exports = (options) => ({
test: /\.jsx?$/, // Transform all .js and .jsx files required somewhere with Babel
exclude: /node_modules/,
use: {
loader: "babel-loader",
loader: 'babel-loader',
},
},
{
@@ -35,23 +35,23 @@ module.exports = (options) => ({
// for a list of loaders, see https://webpack.js.org/loaders/#styling
test: /\.css$/,
exclude: /node_modules/,
use: ["style-loader", "css-loader"],
use: ['style-loader', 'css-loader'],
},
{
// Preprocess 3rd party .css files located in node_modules
test: /\.css$/,
include: /node_modules/,
use: ["style-loader", "css-loader"],
use: ['style-loader', 'css-loader'],
},
{
test: /\.(eot|otf|ttf|woff|woff2)$/,
use: "file-loader",
use: 'file-loader',
},
{
test: /\.svg$/,
use: [
{
loader: "svg-url-loader",
loader: 'svg-url-loader',
options: {
// Inline files smaller than 10 kB
limit: 10 * 1024,
@@ -64,14 +64,14 @@ module.exports = (options) => ({
test: /\.(jpg|png|gif)$/,
use: [
{
loader: "url-loader",
loader: 'url-loader',
options: {
// Inline files smaller than 10 kB
limit: 10 * 1024,
},
},
{
loader: "image-webpack-loader",
loader: 'image-webpack-loader',
options: {
mozjpeg: {
enabled: false,
@@ -87,7 +87,7 @@ module.exports = (options) => ({
optimizationLevel: 7,
},
pngquant: {
quality: "65-90",
quality: '65-90',
speed: 4,
},
},
@@ -96,32 +96,17 @@ module.exports = (options) => ({
},
{
test: /\.html$/,
use: "html-loader",
use: 'html-loader',
},
{
test: /\.(mp4|webm)$/,
use: {
loader: "url-loader",
loader: 'url-loader',
options: {
limit: 10000,
},
},
},
{
test: /\.js$/,
exclude: /node_modules/,
use: [
{
loader: `ifdef-loader`,
options: {
DEBUG: options.mode !== "production",
version: 3,
"ifdef-verbose": true, // add this for verbose output
"ifdef-triple-slash": true, // add this to use double slash comment instead of default triple slash
},
},
],
},
],
},
plugins: options.plugins.concat([
@@ -129,11 +114,11 @@ module.exports = (options) => ({
// inside your code for any environment checks; Terser will automatically
// drop any unreachable code.
new webpack.EnvironmentPlugin({
NODE_ENV: "development",
NODE_ENV: options.mode,
}),
]),
resolve: {
modules: ["src", "node_modules"],
extensions: [".js", ".jsx", ".ts", ".tsx", ".react.js"],
modules: ['src', 'node_modules'],
extensions: ['.js', '.jsx', '.ts', '.tsx', '.react.js'],
},
});