diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..67e1a4a --- /dev/null +++ b/.babelrc @@ -0,0 +1,16 @@ +{ + "presets": [ + [ + "@babel/env", { + useBuiltIns: "usage", + corejs: 3, + } + ], + "@babel/typescript", + "@babel/react", + ], + "plugins": [ + "@babel/proposal-class-properties", + "@babel/proposal-object-rest-spread", + ] +} \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..d0e08a6 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,34 @@ +module.exports = { + 'env': { + 'browser': true, + 'es2021': true, + 'node': true, + }, + 'extends': [ + 'plugin:react/recommended', + 'google', + ], + 'parser': '@typescript-eslint/parser', + 'parserOptions': { + 'ecmaFeatures': { + 'jsx': true, + }, + 'ecmaVersion': 12, + 'sourceType': 'module', + }, + 'plugins': [ + 'react', + '@typescript-eslint', + ], + 'settings': { + 'react': { + 'version': 'detect', + }, + }, + 'rules': { + 'indent': ['error', "tab"], + 'no-tabs': ['error', {'allowIndentationTabs': true}], + 'max-len': ['error', {'tabWidth': 4}], + }, + }; + \ No newline at end of file diff --git a/.gitignore b/.gitignore index d333b23..4747550 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,14 @@ -# ---> Node +# vim +*.swp +*.swo +*~ + +# build and dev deprecated +build +dev +# new build dir +dist + # Logs logs *.log @@ -85,7 +95,7 @@ dist # Gatsby files .cache/ -# Comment in the public line in if your project uses Gatsby and not Next.js +# Comment in the public line in if your project uses Gatsby and *not* Next.js # https://nextjs.org/blog/next-9-1#public-directory-support # public @@ -103,7 +113,3 @@ dist # TernJS port file .tern-port - -# Stores VSCode versions used for testing VSCode extensions -.vscode-test - diff --git a/config/tsconfig.client.json b/config/tsconfig.client.json new file mode 100644 index 0000000..abc051d --- /dev/null +++ b/config/tsconfig.client.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "target": "es5", + "declarationDir": "../dist/types" + }, + "include": [ + "../src/client/**/*" + ] +} diff --git a/config/tsconfig.server.json b/config/tsconfig.server.json new file mode 100644 index 0000000..cc57326 --- /dev/null +++ b/config/tsconfig.server.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "target": "es6", + "declarationDir": "../dist/types" + }, + "include": [ + "../src/server/**/*" + ] +} diff --git a/config/webpack.client.common.js b/config/webpack.client.common.js new file mode 100644 index 0000000..6b33b86 --- /dev/null +++ b/config/webpack.client.common.js @@ -0,0 +1,28 @@ +const path = require('path'); +const nodeExternals = require('webpack-node-externals'); +const EsLint = require('eslint-webpack-plugin'); + +module.exports = { + entry: path.resolve(__dirname, '../src/client/main.tsx'), + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, '../dist/client'), + }, + target: 'web', + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'] + }, + module: { + rules: [{ + test: /\.tsx?$/, + loader: 'babel-loader', + include: path.join(__dirname, '../src/client'), + }], + }, + plugins: [ + new EsLint({ + extensions: ['.ts', '.tsx'], + context: path.join(__dirname, '../src/client'), + }), + ], +}; diff --git a/config/webpack.client.dev.js b/config/webpack.client.dev.js new file mode 100644 index 0000000..aa3fc2f --- /dev/null +++ b/config/webpack.client.dev.js @@ -0,0 +1,9 @@ +const path = require('path'); +const { merge } = require('webpack-merge'); +const common = require('./webpack.client.common.js'); + +module.exports = merge(common, { + devtool: 'eval-cheap-module-source-map', + mode: 'development', + watch: true +}); diff --git a/config/webpack.client.prod.js b/config/webpack.client.prod.js new file mode 100644 index 0000000..47b3edf --- /dev/null +++ b/config/webpack.client.prod.js @@ -0,0 +1,14 @@ +const path = require('path'); +const { merge } = require('webpack-merge'); +const common = require('./webpack.client.common.js'); +const TerserPlugin = require('terser-webpack-plugin'); + +module.exports = merge(common, { + mode: 'production', + optimization: { + minimize: true, + minimizer: [new TerserPlugin({ + parallel: true + })] + } +}); diff --git a/config/webpack.server.common.js b/config/webpack.server.common.js new file mode 100644 index 0000000..9e740ea --- /dev/null +++ b/config/webpack.server.common.js @@ -0,0 +1,29 @@ +const path = require('path'); +const nodeExternals = require('webpack-node-externals'); +const EsLint = require('eslint-webpack-plugin'); + +module.exports = { + entry: path.resolve(__dirname, '../src/server/main.ts'), + output: { + filename: 'bundle.js', + path: path.resolve(__dirname, '../dist/server'), + }, + target: 'node', + externals: [nodeExternals()], + resolve: { + extensions: ['.ts', '.tsx', '.js', '.json'] + }, + module: { + rules: [{ + test: /\.tsx?$/, + loader: 'babel-loader', + include: path.join(__dirname, '../src/server'), + }], + }, + plugins: [ + new EsLint({ + extensions: ['.ts', '.tsx'], + context: path.join(__dirname, '../src/server'), + }), + ], +}; diff --git a/config/webpack.server.dev.js b/config/webpack.server.dev.js new file mode 100644 index 0000000..73bbd8f --- /dev/null +++ b/config/webpack.server.dev.js @@ -0,0 +1,9 @@ +const path = require('path'); +const { merge } = require('webpack-merge'); +const common = require('./webpack.server.common.js'); + +module.exports = merge(common, { + devtool: 'eval-cheap-module-source-map', + mode: 'development', + watch: true +}); diff --git a/config/webpack.server.prod.js b/config/webpack.server.prod.js new file mode 100644 index 0000000..91dfae9 --- /dev/null +++ b/config/webpack.server.prod.js @@ -0,0 +1,14 @@ +const path = require('path'); +const { merge } = require('webpack-merge'); +const common = require('./webpack.server.common.js'); +const TerserPlugin = require('terser-webpack-plugin'); + +module.exports = merge(common, { + mode: 'production', + optimization: { + minimize: true, + minimizer: [new TerserPlugin({ + parallel: true + })] + } +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..63d38d8 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "name": "weblgl", + "version": "1.0.0", + "description": "A simple WebGL app to demonstrate my skills", + "scripts": { + }, + "repository": { + "type": "git", + "url": "https://git.gaetanbrochard.dev/gbrochar/weblgl.git" + }, + "author": "gbrochar", + "license": "AGPL-3.0-only" +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0a1329b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "noFallthroughCasesInSwitch": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "esModuleInterop": true, + "noUnusedLocals": true, + "noImplicitAny": true, + "declaration": true, + "jsx" : "preserve", + "module": "commonjs", + "strict": true + }, + "exclude": [ + "node_modules", + "config", + "views", + "dist" + ] +}