I was reading this webpack tutorial:
https://webpack.github.io/docs/usage.html
It says it bundles the src files and node_modules. If I want to add another .j
In response to Dmitry's answer:
- add the file path to entry list before app.js
This has the effect that you will get a bundled .js file for each entry point, which you might not want.
- require this file from app.js
You might not have access to app.js
if it is written dynamically, or for whatever reason you might not want to edit app.js
.
You can use webpack-inject-plugin to inject any JS code as string into the resulting .js bundle created by webpack. This way you can read the File you want to inject as a string (e.g. fs.readFile
in nodejs) and inject it with the plugin.
The start point for code is the entry
field in config. In your config entry point is the list of files. Webpack gets all, resolve their dependencies and output in one file.
You have two options for adding third party script: