-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Changing the output file to main.js
#1951
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
Conversation
`npx webpack` creates an output file as`main.js` instead of 'bundle.js`. We need to point to `main.js` in the `index.html'
</body> | ||
</html> | ||
``` | ||
|
||
In this setup, `index.js` explicitly requires `lodash` to be present, and binds it as `_` (no global scope pollution). By stating what dependencies a module needs, webpack can use this information to build a dependency graph. It then uses the graph to generate an optimized bundle where scripts will be executed in the correct order. | ||
|
||
With that said, let's run `npx webpack` with our script as the [entry point](/concepts/entry-points) and `bundle.js` as the [output](/concepts/output). The `npx` command, which ships with Node 8.2 or higher, runs the webpack binary (`./node_modules/.bin/webpack`) of the webpack package we installed in the beginning: | ||
With that said, let's run `npx webpack` with our script as the [entry point](/concepts/entry-points) and `main.js` as the [output](/concepts/output). The `npx` command, which ships with Node 8.2 or higher, runs the webpack binary (`./node_modules/.bin/webpack`) of the webpack package we installed in the beginning: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to say:
... and main.js
as the default [output]...
Please add into description that it: Fixes #1949 |
</body> | ||
</html> | ||
``` | ||
|
||
In this setup, `index.js` explicitly requires `lodash` to be present, and binds it as `_` (no global scope pollution). By stating what dependencies a module needs, webpack can use this information to build a dependency graph. It then uses the graph to generate an optimized bundle where scripts will be executed in the correct order. | ||
|
||
With that said, let's run `npx webpack` with our script as the [entry point](/concepts/entry-points) and `bundle.js` as the [output](/concepts/output). The `npx` command, which ships with Node 8.2 or higher, runs the webpack binary (`./node_modules/.bin/webpack`) of the webpack package we installed in the beginning: | ||
With that said, let's run `npx webpack` with our script as the [entry point](/concepts/entry-points) and `main.js` as the [output](/concepts/output). The `npx` command, which ships with Node 8.2 or higher, runs the webpack binary (`./node_modules/.bin/webpack`) of the webpack package we installed in the beginning: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix @sakshi27, do you think we can rephrase this paragraph? this is my proposal:
We can run `npx webpack` with `./src/index.js` as the [entry point](/concepts/entry-points) and `main.js` as the default [output](/concepts/output).
>T The `npx` command ships with Node 8.2 or higher and let us run the webpack binary (`./node_modules/.bin/webpack`) we installed above.
The Conclusion section also references the non-existent |
@EugeneHlushko @jeremenichelli I had closed 3 PRs with these same changes, your suggestions are welcome but are out of the scope of this PR, I really want to merge this one ASAP since it is a page directly linked from the homepage. |
No problem @montogeek, merge this and create an issue with the feedback here. I did that for the split chunks plugin. The important thing is to keep track of what's left to be done so it doesn't get lost in the conversations. |
Thanks |
npx webpack
creates an output file asmain.js
instead of 'bundle.js. We need to point to
main.jsin the
index.html'describe your changes...