Skip to content

Commit

Permalink
Big rework to use esbild
Browse files Browse the repository at this point in the history
  • Loading branch information
Olliebrown committed Oct 26, 2021
1 parent 7390291 commit d8c72e7
Show file tree
Hide file tree
Showing 8 changed files with 6,096 additions and 966 deletions.
4 changes: 0 additions & 4 deletions .babelrc

This file was deleted.

75 changes: 60 additions & 15 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,68 @@
{
"plugins": [
"react",
"react-hooks"
],
"env": {
"browser": true,
"es2021": true
},
"globals": {
"_VER_": false,
"_DEV_": false
},
"extends": [
"standard",
"eslint:recommended",
"plugin:react/recommended"
"plugin:react/all",
"plugin:react-hooks/recommended",
"standard"
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 2017,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"react-hooks"
],
"settings": {
"react": { "version": "detect" }
},
"rules": {
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn",
// Disable some of the react rules
"react/jsx-newline": "off",
"react/jsx-max-depth": "off",
"react/jsx-curly-brace-presence": "off",
"react/jsx-sort-default-props": "off",
"react/jsx-props-no-spreading": "off",
"react/jsx-max-props-per-line": "off",
"react/jsx-sort-props": "off",
"react/jsx-no-bind": "off",
"react/jsx-fragments": "off",
"react/require-optimization": "off",
"react/sort-prop-types": "off",
"react/sort-comp": "off",
"react/static-property-placement": "off",
"react/no-array-index-key": "off",
"react/no-multi-comp": "off",
"react/jsx-no-literals": "off",

// Lower some react rules to be warnings
"react/jsx-indent": ["warn", 2],
"react/jsx-indent-props": ["warn", 2],
"react/jsx-one-expression-per-line": ["warn", { "allow": "single-child" }],
"react/jsx-first-prop-new-line": "warn",
"react/jsx-curly-newline": "warn",
"react/jsx-tag-spacing": "warn",
"react/jsx-handler-names": "warn",
"react/jsx-closing-tag-location": "warn",
"react/jsx-closing-bracket-location": "warn",
"react/jsx-curly-spacing": "warn",
"react/forbid-component-props": ["warn", { "forbid": ["style"] }],
"react/destructuring-assignment": "warn",
"react/require-default-props": "warn",

// Convert many standard.js rules to warnings instead of errors
"default-case-last": "warn",
"import/no-unresolved": [2],
"indent": "warn",
"quotes": "warn",
Expand All @@ -31,6 +75,7 @@
"brace-style": "warn",
"curly": "warn",
"no-multiple-empty-lines": "warn",
"no-throw-literal": "off",
"operator-linebreak": "warn",
"one-var": "warn",
"no-cond-assign": "warn",
Expand All @@ -52,13 +97,13 @@
"no-tabs": "warn",
"no-trailing-spaces": "warn",
"padded-blocks": "warn",
"semi": [ "warn", "never" ],
"semi": ["warn", "never"],
"semi-spacing": "warn",
"space-before-blocks": "warn",
"space-in-parens": "warn",
"space-unary-ops": "warn",
"spaced-comment": "warn",
"template-curly-spacing": "warn",
"yoda": "warn"
"yoda": "warn"
}
}
}
50 changes: 50 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Import esbuild
import ESBuild from 'esbuild'

// Is server requested?
const serve = process.argv.some((arg) => (arg.toLowerCase() === 'serve'))

// Is this a dev build?
const _DEV_ = process.argv.some((arg) => (arg.toLowerCase() === 'dev'))

// esbuild options
const options = {
// List of all separate entry points
entryPoints: [
'./src/main.jsx'
],

// Configure output location and names
outdir: './public',
entryNames: '/[name]',

// Configure output types
bundle: true,
sourcemap: _DEV_,
minify: (!_DEV_),

// Define important variables
define: {
_VER_: `"${process.env.npm_package_version}"`,
_DEV_,
'process.env.NODE_ENV': (_DEV_ ? '"development"' : '"production"')
}
}

// Start up server if requested
if (serve) {
ESBuild.serve({ port: 3000, servedir: 'public' }, options)
.then(server => {
console.log(`Serving dev code at ${server.host}:${server.port}`)
})
.catch(() => {
process.exit(1)
})
} else {
// Attempt to build
ESBuild.build(options).catch(
() => {
process.exit(1)
}
)
}
Loading

0 comments on commit d8c72e7

Please sign in to comment.