I am currently in the process of enhancing an application to make it more manageable. The application is currently utilizing a large JS file with numerous JS classes. I have decided to organize the code by placing each JS class in its own separate JS file.
My goal is to leverage Parcel to merge all JS files into one single JS file that can be easily linked from my index.html
.
To achieve this, I have modified each main class by adding export default
. For example: export default class MyJSClass
. Then, I import these classes as needed from an index.js
file like so:
import MyJSClass from './MyJSClass.js';
The current framework structure of the application is as follows:
resources
|-Public
|-JS
|-singleHugeJSFile.js
|-Templates
|-index.html
I intend to utilize Parcel while maintaining the same structure, which would look like:
resources
|-Public
|-JS
|-index.js // Entry point JS file
|-MyJSClass.js
|-SomeOtherClass.js
|-AnotherClass.js
...
|-Templates
|-index.html
To start, I have installed Parcel within the resources directory and executed the following command:
parcel build public/js/index.js
However, this generates files in the dist directory.
How can I generate a single entry JS file containing all JS using Parcel while preserving the original application structure, allowing me to maintain the default path for linking to this JS file from index.html?