-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make extension compatible with Create React App v2.x #2
Comments
Webpack version is updated in the 2.x version of webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization Here are the changes you need to do to make it compatible:
Rest of the implementation is same as mentioned in the blog |
Awesome!! 🎉 |
This is spot on but I still found it a bit confusing with create-react-app 2.1.1 ejected. For anyone else slightly confused: There was no Here's my entry: {
app: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
isEnvDevelopment &&
require.resolve("react-dev-utils/webpackHotDevClient"),
// Finally, this is your app's code:
paths.appIndexJs
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
].filter(Boolean),
content: "./src/content.js"
}, I also had more "content_scripts": [
{
"matches": ["https://google.com/"],
"css": ["/static/css/app.css", "/static/css/content.css"],
"js": ["/static/js/0.js", "/static/js/3.js", "/static/js/content.js"],
"run_at": "document_end"
}
], |
I believe this needs to be reopened for the latest version |
@satendra02 I have it working now but there were required changes. For example, I don't have to do
I believe I was able to change it to where there is only one output file. I don't recall what I did as this was a month or so ago. When I go through the code again I'll post an update here. Also, there was a webpack change that required some research. |
@Romstar That's great to hear that you made it work for the latest version of Please post the changes you did whenever you get time, It will help others if they face the same issue. You can also create a pull request for the same I will definitely merge it to master Thanks |
@danielgwilson These changes result in the following error after running
|
Hi @MrGiga , I had the same problem, to solve that, I did this configuration in my entry point: entry: {
main: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
isEnvDevelopment &&
require.resolve("react-dev-utils/webpackHotDevClient"),
// Finally, this is your app's code:
paths.appIndexJs
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
].filter(Boolean),
content: "./src/content.js"
}, This problem happened because To solve this, instead of |
Here's the list of changes I made for CRA v3.3
Delete
Change main.filter to app.filter:
|
Hey @chrisstpierre, you can convert it to an object like this: entry: {
main: [
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
isEnvDevelopment &&
require.resolve("react-dev-utils/webpackHotDevClient"),
// Finally, this is your app's code:
paths.appIndexJs
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
].filter(Boolean),
content: "./src/content.js",
background: "./src/background.js"
}, I hope it helps :-) |
webpack.config.prod.js file missing after Ejecting create-react-app (npm run eject), my question from where I can set multiple entry points in webpack file. |
Hi @alphaq1205 check above @danielgwilson answer the file name must be |
@carlosvq , definitely a solution for the problem, you and @danielgwilson saved my day. Thanks! |
@lucasgit2000 @satendra02 @carlosvq @chrisstpierre Does anyone have a complete list of changes that they need to make to get this to work with the current ejection of npx create-react-app ejection? I'm quite new to React and configuring webpack.config.js and matching it correctly to my manifest is quite confusing with the different answers above |
Hi, These were the steps I took:
Optional configurations that I think make sense
Note on cloning template:I was not able to install the dependencies. I have created an issue #50. Note on create-react-app@4.0.0:If you are using v4.0.0 there is currently a bug which occurs when you eject. A pull request has been merged, but not been released as of November 13th 2020. So if you want to eject, here is a clean bug fix.. @Adrian-Samuel were you looking for something like this? |
I was running into an issue with: I needed to add: |
…hich produces a different Webpack file. need to make some modifications according to github.com/satendra02/react-chrome-extension/issues/2
Error: Cannot find module './polyfills
'After running
yarn run eject
The text was updated successfully, but these errors were encountered: