-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0147e38
commit 6d04640
Showing
10 changed files
with
471 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
node_modules | ||
*.bundle.js | ||
*.bundle.js.map | ||
*.bundle.js.LICENSE.txt | ||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.PHONY: hosting | ||
hosting: | ||
cp -R dist/* ../../hosting/html/js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
const { build } = require('esbuild'); | ||
|
||
const isDev = process.env.NODE_ENV === 'development'; | ||
const jsxPluginReact17 = { | ||
name: 'jsx-react-17', | ||
setup(build) { | ||
const fs = require('fs'); | ||
const babel = require('@babel/core'); | ||
const plugin = require('@babel/plugin-transform-react-jsx').default( | ||
{}, | ||
{ runtime: 'automatic' }, | ||
); | ||
|
||
build.onLoad({ filter: /\.[t,j]sx$/ }, async (args) => { | ||
const jsx = await fs.promises.readFile(args.path, 'utf8'); | ||
const result = babel.transformSync(jsx, { plugins: [plugin] }); | ||
return { contents: result.code }; | ||
}); | ||
}, | ||
}; | ||
|
||
build({ | ||
define: { 'process.env.NODE_ENV': process.env.NODE_ENV }, | ||
target: 'es2015', | ||
target: 'es2019', | ||
platform: 'browser', | ||
entryPoints: ['src/pages/indext.tsx'], | ||
outdir: 'dist', | ||
outfile: 'dist/react-esbuild.bundle.js', | ||
bundle: true, | ||
minify: !isDev, | ||
minify: true, | ||
sourcemap: true, | ||
plugins: [jsxPluginReact17], | ||
}).catch((err) => console.log(`Error: ${JSON.stringify(err)}`)); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import ReactDOM from 'react-dom'; | ||
|
||
const App = () => <h1>Hello World</h1>; | ||
|
||
ReactDOM.render(<App />, document.getElementById('root')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es2019", | ||
"module": "esnext", | ||
"moduleResolution": "node", | ||
"jsx": "react-jsx", | ||
"strict": true, | ||
"esModuleInterop": true, | ||
"resolveJsonModule": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"baseUrl": "src", | ||
"paths": { | ||
"@/*": ["./*"], | ||
"@components/*": ["components/*"] | ||
} | ||
}, | ||
"exclude": ["./node_modules"] | ||
} |
Oops, something went wrong.