Skip to content

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

Merged
merged 3 commits into from
Apr 5, 2018
Merged

Conversation

sakshi27
Copy link
Contributor

npx webpack creates an output file asmain.js instead of 'bundle.js. We need to point to main.jsin theindex.html'

describe your changes...

  • Read and sign the CLA. PRs that haven't signed it won't be accepted.
  • Make sure your PR complies with the writer's guide.
  • Review the diff carefully as sometimes this can reveal issues.
  • Remove these instructions from your PR as they are for your eyes only.

`npx webpack` creates an output file as`main.js` instead of 'bundle.js`. We need to point to `main.js` in the `index.html'
@jsf-clabot
Copy link

jsf-clabot commented Mar 24, 2018

CLA assistant check
All committers have signed the CLA.

</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:
Copy link
Member

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]...

@EugeneHlushko
Copy link
Member

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:
Copy link
Member

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.

@xx10t4
Copy link

xx10t4 commented Mar 31, 2018

The Conclusion section also references the non-existent dist/bundle.js file.

@montogeek
Copy link
Member

@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.

@jeremenichelli
Copy link
Member

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.

@montogeek montogeek merged commit ce3e350 into webpack:master Apr 5, 2018
@montogeek
Copy link
Member

Thanks

Munter added a commit that referenced this pull request Apr 9, 2018
* origin/master:
  docs(configuration) Add space above comments (#1997)
  docs(): Merge the next branch (#1993)
  docs(api): Add -o to command (#1995)
  docs(configuration) Fixed an a/an error in `/configuration/module` (#1990)
  docs(guides) Changing the output file to `main.js` (#1951)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants