Skip to content

Commit

Permalink
Merge pull request #572 from 3DStreet/react-refresh
Browse files Browse the repository at this point in the history
Add react-refresh to make hmr work for jsx
  • Loading branch information
kfarr authored Jun 10, 2024
2 parents ede3576 + 307213a commit 870ef19
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 80 deletions.
226 changes: 151 additions & 75 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@babel/eslint-parser": "^7.24.5",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.23.3",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@storybook/addon-essentials": "^7.6.3",
"@storybook/addon-interactions": "^7.6.3",
"@storybook/addon-links": "^7.6.3",
Expand All @@ -58,8 +59,8 @@
"approvals": "^7.1.0",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^6.10.0",
"cross-env": "^7.0.3",
"css-loader": "^6.10.0",
"css-minimizer-webpack-plugin": "^6.0.0",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.57.0",
Expand All @@ -75,6 +76,7 @@
"nyc": "^15.1.0",
"prettier": "^3.1.0",
"pretty": "^2.0.0",
"react-refresh": "^0.14.2",
"resolve-url-loader": "^5.0.0",
"rewire": "^7.0.0",
"sass": "^1.69.5",
Expand Down Expand Up @@ -105,4 +107,4 @@
"eslint"
]
}
}
}
16 changes: 13 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const webpack = require('webpack');
const path = require('path');
const Dotenv = require('dotenv-webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

module.exports = {
mode: 'development',
Expand All @@ -18,8 +19,13 @@ module.exports = {
},
devtool: 'source-map',
entry: {
core: { import: './src/index.js', filename: 'aframe-street-component.js' },
editor: { import: './src/editor/index.js', filename: '3dstreet-editor.js' }
editor: {
import: ['./src/editor/index.js'],
filename: '3dstreet-editor.js'
}
// react-refresh doesn't work with multiple entry points so we use the production build of aframe-street-component.js in development,
// you will need to run `npm run dist` to see your changes or uncomment temporarily the following line and run `npm start` again.
// core: { import: './src/index.js', filename: 'aframe-street-component.js' }
},
output: {
publicPath: '/dist/',
Expand All @@ -31,6 +37,7 @@ module.exports = {
three: 'THREE'
},
plugins: [
new ReactRefreshWebpackPlugin(),
new Dotenv({
path: './config/.env.development'
}),
Expand All @@ -51,7 +58,10 @@ module.exports = {
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
loader: 'babel-loader',
options: {
plugins: ['react-refresh/babel']
}
}
},
{
Expand Down

0 comments on commit 870ef19

Please sign in to comment.