first commit

This commit is contained in:
ryanwong
2022-11-26 01:23:44 -05:00
commit 02843b95c9
2776 changed files with 102795 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": ["plugin:react/recommended", "airbnb"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["react", "@typescript-eslint", "import"],
"rules": {
"no-shadow": "off",
"no-useless-constructor": "off",
"no-use-before-define": [0],
"@typescript-eslint/no-use-before-define": [1],
"no-unused-vars": 2, //Keep this as the files in this folder don't use TypeScript.
"@typescript-eslint/no-unused-vars": "error",
"react/jsx-filename-extension": [1, { "extensions": [".tsx", ".jsx"] }],
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }],
"max-len": "off",
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
],
"jsx-a11y/anchor-is-valid": 0,
"jsx-a11y/label-has-associated-control": "off",
"indent": "off",
"no-case-declarations": "off",
"no-restricted-globals": "off",
"implicit-arrow-linebreak": "off",
"import/no-webpack-loader-syntax": "off",
"linebreak-style": "off",
"import/no-unresolved": "off"
}
}
+8
View File
@@ -0,0 +1,8 @@
//Determine which env file to use, based on the environment
const root = require('./paths').root;
const envPaths = {
development: `${root}/.env.development`,
staging: `${root}/.env.staging`,
production: `${root}/.env`,
};
module.exports = envPaths[process.env.NODE_ENV] || envPaths['production'];
+17
View File
@@ -0,0 +1,17 @@
const path = require('path');
module.exports = {
//Root of the application
root: path.normalize(path.resolve('./')),
// Source files
src: path.normalize(path.resolve(__dirname, '../src')),
assets: path.normalize(path.resolve(__dirname, '../src/shared/assets')),
// Production build files
build: path.normalize(path.resolve(__dirname, '../dist')),
// Static files that get copied to build folder
public: path.normalize(path.resolve(__dirname, '../public')),
};
+155
View File
@@ -0,0 +1,155 @@
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ESLintPlugin = require('eslint-webpack-plugin');
const Dotenv = require('dotenv-webpack');
const path = require('path');
const paths = require('./paths');
const envPath = require('./envPath');
module.exports = {
// Where webpack looks to start building the bundle
entry: [path.normalize(`${paths.src}/index.tsx`)],
// Where webpack outputs the assets and bundles
output: {
path: path.normalize(paths.build),
filename: '[name].bundle.js',
publicPath: '/',
},
// Customize the webpack build process
plugins: [
// Removes/cleans build folders and unused assets when rebuilding
new CleanWebpackPlugin(),
// Puts variables in .env files into process.env
new Dotenv({
path: path.normalize(envPath),
}),
new CopyWebpackPlugin({
patterns: [
{
from: path.normalize(`${paths.src}/netlify-redirect`),
to: path.normalize(paths.build),
globOptions: {
ignore: ['*.DS_Store'],
},
noErrorOnMissing: true,
},
{
from: './node_modules/@pdftron/webviewer/public',
to: path.normalize(`${paths.build}/public/webviewer`),
globOptions: {
ignore: ['*.DS_Store'],
},
},
],
}),
// Generates an HTML file from a template
new HtmlWebpackPlugin({
title: 'Company',
inject: 'body',
appMountId: 'app',
favicon: paths.src + '/images/favicon.png',
template: `${paths.src}/index.html`, // template file
filename: 'index.html', // output file
// ', //Lets us load the appropriate dev scripts in the html
axios: 'https://cdn.jsdelivr.net/npm/axios@0.21.1/dist/axios.min.js',
bootstrap: 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/js/bootstrap.min.js',
bootStrapCss: 'https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css',
react: 'https://cdnjs.cloudflare.com/ajax/libs/react/17.0.1/umd/react.production.min.js',
reactDom: 'https://cdn.jsdelivr.net/npm/react-dom@17.0.2/index.min.js', // Lets us load the appropriate dev scripts in the html
popper: 'https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/cjs/popper.min.js',
redux: 'https://cdn.jsdelivr.net/npm/redux@4.1.0/lib/redux.min.js',
reactRedux: 'https://cdn.jsdelivr.net/npm/react-redux@7.2.4/lib/index.min.js',
reactRouterDom: 'https://cdn.jsdelivr.net/npm/react-router-dom@5.2.0/index.min.js',
}),
// ESLint configuration
new ESLintPlugin({
files: ['.', 'src', 'config'],
formatter: 'table',
failOnError: false,
emitWarning: true,
}),
// Prettier configuration
// new PrettierPlugin(),
],
resolve: {
alias: {
RocketAssets: `${paths.src}/shared/assets`,
Components: path.normalize(`${paths.src}/shared/components`),
Containers: path.normalize(`${paths.src}/shared/containers`),
Context: path.normalize(`${paths.src}/shared/context`),
HOC: path.normalize(`${paths.src}/shared/hoc`),
Utils: path.normalize(`${paths.src}/shared/utils`),
Hooks: path.normalize(`${paths.src}/shared/hooks`),
Themes: path.normalize(`${paths.src}/shared/themes`),
Routes: path.normalize(`${paths.src}/routes`),
},
symlinks: false,
cacheWithContext: false,
extensions: ['.ts', '.tsx', '.js', '.json', '.jsx', '.mjs', '.css', '.scss', '.sass'],
},
// Determine how modules within the project are treated
module: {
rules: [
// JavaScript: Use Babel to transpile JavaScript files
{
test: /\.(js|jsx|tsx|ts|mjs)$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
},
{
test: /\.(ts|tsx)$/,
use: [
{
loader: 'ts-loader',
},
],
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
{
test: /\.(?:ico|png|jpg|gif|jpeg|ttf)$/,
type: 'assets/resource',
},
// Images: Copy image files to build folder
{ test: /\.(?:ico|gif|png|jpg|jpeg)$/i, type: 'assets' },
// Fonts and SVGs: Inline files
// { test: /\.(woff(2)?|eot|ttf|otf|svg|)$/, type: 'assets/inline' },
],
},
// externals: {
// axios: {
// amd: 'axios',
// },
// bootstrap: 'bootstrap',
// react: 'React', // Case matters here
// 'react-dom': 'ReactDOM',
// 'react-router-dom': 'react-router-dom',
// popperCore: {
// root: 'PopperJS',
// commonjs2: 'popper.js',
// commonjs: 'popper.js',
// amd: 'popper.js',
// },
// 'react-router-dom': 'ReactRouter',
// redux: 'redux',
// 'react-redux': 'react-redux',
// },
// externalsPresets: { web: false, webAsync: true },
// optimization: {
// // fix node modules not packaged into zip
// concatenateModules: false,
// },
};
+76
View File
@@ -0,0 +1,76 @@
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const common = require('./webpack.base.js');
const paths = require('./paths');
const path = require('path');
module.exports = merge(common, {
// Set the mode to development or production
mode: 'development',
// Control how source maps are generated
devtool: 'inline-source-map',
output: {
path: path.normalize(paths.build),
publicPath: '/',
filename: 'js/[name].[contenthash].bundle.js',
},
// Spin up a server for quick development
devServer: {
historyApiFallback: true,
contentBase: path.normalize(paths.build),
index: '/',
open: true,
compress: true,
hot: true,
port: 3000,
host: 'test.rocketplantech.com',
https: true,
noInfo: true, //This turns off information regarding the bundle. Set to false if you need to view the messages
},
module: {
rules: [
// Styles: Inject CSS into the head with source maps
{
test: /\.(scss|css)$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
sourceMap: true,
importLoaders: 1,
// modules: true,
modules: {
localIdentName: '[name]__[local]___[hash:base64:5]',
},
},
},
{ loader: 'postcss-loader', options: { sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } },
],
include: /\.module\.css$/i,
},
{
test: /\.(scss|css)$/i,
use: [
'style-loader',
// 'css-loader',
{
loader: 'css-loader',
options: { sourceMap: true, importLoaders: 1 },
},
{ loader: 'postcss-loader', options: { sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } },
],
exclude: /\.module\.css$/i,
},
],
},
plugins: [
// Only update what has changed on hot reload
new webpack.HotModuleReplacementPlugin(),
],
});