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

+3 -1
View File
@@ -64,6 +64,7 @@
"html-webpack-plugin": "^4.3.0",
"ifdef-loader": "^2.1.5",
"lint-staged": "^10.5.3",
"react-devtools": "^4.10.1",
"react-test-renderer": "^16.13.1",
"style-loader": "^0.23.1",
"svg-url-loader": "^2.3.2",
@@ -77,7 +78,8 @@
"start": "react-scripts start",
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
"format": "prettier --write src/**/*.{js,jsx,ts,tsx,json,css,scss,md}",
"build": "cross-env NODE_ENV=production webpack --config webpack/webpack.resources.js --color -p --progress --hide-modules --display-optimization-bailout",
"build": "cross-env NODE_ENV=production webpack --config webpack/prod.config.js --color -p --progress --hide-modules --display-optimization-bailout",
"build:dev": "cross-env NODE_ENV=development webpack --config webpack/dev.config.js --color -p --progress --hide-modules --display-optimization-bailout --analyze",
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
"eject": "react-scripts eject",
+2 -1
View File
@@ -15,7 +15,8 @@
"noImplicitAny": false,
"noEmit": true,
"jsx": "react",
"strictNullChecks": false
"strictNullChecks": false,
"sourceMap": true
},
"include": ["src"]
}
+21
View File
@@ -0,0 +1,21 @@
const path = require('path');
const CommonWebpack = require('./webpack.common');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = CommonWebpack({
mode: 'development',
devtool: 'inline-source-map',
entry: ['react-devtools', './src/index.tsx'],
// Output path
output: {
path: path.resolve(process.cwd(), 'build'),
filename: 'index.js',
},
plugins: [
new HtmlWebpackPlugin({
template: 'public/index.html',
inject: true,
minify: false,
}),
],
});
+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'],
},
});
@@ -1,12 +1,10 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ResourceManifestPlugin = require('./webpack.fxmanifest.plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = require('./webpack.common')({
mode: 'production',
// In production, we skip all hot-reloading stuff
entry: [path.join(process.cwd(), 'src/index.tsx')],
plugins: [
@@ -26,7 +24,6 @@ module.exports = require('./webpack.common')({
},
inject: true,
}),
new ResourceManifestPlugin(),
new CopyPlugin({
patterns: [
{
+686 -16
View File
File diff suppressed because it is too large. Load diff