Skip to content

Commit

Permalink
fixed react dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LiveDuo committed Nov 7, 2023
1 parent a89e7d5 commit 583e15c
Show file tree
Hide file tree
Showing 4 changed files with 210 additions and 7 deletions.
1 change: 1 addition & 0 deletions dev/react-project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"concurrently": "^6.4.0",
"css-loader": "^6.8.1",
"esbuild-loader": "^4.0.2",
"copy-webpack-plugin": "^11.0.0",
"html-webpack-plugin": "^5.5.3",
"http-server": "^14.0.0",
"style-loader": "^3.3.3",
Expand Down
9 changes: 3 additions & 6 deletions dev/react-project/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const path = require('path')

const HtmlWebpackPlugin = require('html-webpack-plugin')
const HtmlPlugin = require('html-webpack-plugin')
const CopyPlugin = require('copy-webpack-plugin')

module.exports = {
mode: process.env.NODE_ENV ?? 'development',
Expand All @@ -27,11 +28,7 @@ module.exports = {
resolve: {
fallback: { crypto: false },
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html',
}),
],
plugins: [new HtmlPlugin({ template: './public/index.html' }), new CopyPlugin({ patterns: ['data/*.html'] })],
devServer: {
compress: true,
port: 3000,
Expand Down
2 changes: 1 addition & 1 deletion lib/client/vanilla/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ContentProviderReact = () => {
}

const url = location.pathname === '/' ? '/default.html' : `${location.pathname}.html`
const _data = await fetch(url).then((r) => r.text())
const _data = await fetch(`/data/${url}`).then((r) => r.text())
setData([{ content: _data, name: location.pathname }])
setLoaded(true)
}
Expand Down
205 changes: 205 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 583e15c

Please sign in to comment.