Merge pull request #81 from project-error/enhance/debug

Enhance/debug - Several changes to improve dev experience
This commit is contained in:
Christopher Gjelten authored and GitHub committed 2021-02-14 23:21:52 +01:00
commit a5491302b6
9 files changed
+747 -109

No files matched your search

+23 -1
View File
@@ -91,7 +91,29 @@ The Installation Steps assumes you have the following prerequisites:
- If iteration on UI changes run the project with `yarn watch` which will monitor the JavaScript project and rebuild when you make code changes and then do `ensure new-phone-who-dis` after making your change.
- Avoid commiting `index.html` as the development version overrides the production version
#### Important Note
#### React Devtools
When in development mode, the bundle includes a standalone React DevTools module, that allows access to react-devtools comparable to the browser environment.
First ensure you have react-devtools installed globally by running one of the following commands:
#### Yarn
```shell
yarn global add react-devtools
```
#### NPM
```shell
npm install -g react-devtools
```
Then run this command from your preffered terminal:
```shell
react-devtools
```
Now start your `ensure NPWD` with the development build, and you should have access to the React DevTools just as you would in the browser!
### Important Note
- By installing NPWD you agree to the use of the following diagnostic package, Sentry, (in use within the React portion of NPWD), that automatically
uploads relevant sesssion details and stack traces whenever an exception is thrown. We use these metrics to further
+3
View File
@@ -4,6 +4,9 @@
"husky": "^4.3.8",
"lerna": "^3.22.1"
},
"scripts": {
"build": "lerna run build --concurrency 1"
},
"husky": {
"hooks": {
"pre-commit": "lerna run --concurrency 1 --stream precommit --since HEAD --exclude-dependents"
+2
View File
@@ -66,6 +66,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",
@@ -81,6 +82,7 @@
"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": "yarn copy:config && cross-env NODE_ENV=production webpack --config webpack/webpack.resources.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,
}),
],
});
@@ -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: [
{
+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,55 +0,0 @@
const path = require("path");
const defaultOptions = {
itemsFromCompilation: (compilation) => Object.keys(compilation.assets),
output: "phonemanifest.lua",
};
const makeDefault = (object, ...sources) => {
object = Object(object);
sources.forEach((source) => {
if (source != null) {
source = Object(source);
for (const key in source) {
const value = object[key];
if (
value === undefined ||
(eq(value, objectProto[key]) && !hasOwnProperty.call(object, key))
) {
object[key] = source[key];
}
}
}
});
return object;
};
function ResourceManifestPlugin(options) {
makeDefault(this, options, defaultOptions);
}
const pluginName = "fivem-manifest-plugin";
ResourceManifestPlugin.prototype.apply = function (compiler) {
const { itemsFromCompilation, output } = this;
compiler.hooks.emit.tap(pluginName, (compilation) => {
const assets = itemsFromCompilation(compilation);
const result = format(
assets,
compilation.options.output.path.split("\\").pop()
);
compilation.assets[output] = {
source: () => Buffer.from(result),
size: () => Buffer.byteLength(result),
};
});
};
function format(assets, path) {
return `
ui_page "${path}/index.html"
files{${assets.map((asset) => `"${path}/${asset}"`).join(",")}}
`;
}
module.exports = ResourceManifestPlugin;
+678 -16
View File
File diff suppressed because it is too large. Load diff