ng build - Add option to save bundled js files in different directory and index in different directory
Here is a feature request.
When we build a project using ng build command, it creates a folder dist and place all bundles and index file in it. I know that we can specify the outdir in angular-cli.json and cli will generate all bundles and index.html file in the specified folder.
What if there is a need to put the bundled js files in a separate directory and index file in separate directory e.g
bundled js in /dist/js/ folder
and index file in /dist/ folder
I tried, copying the generated js bundles to the dist/js folder and updated the paths in index file but it didn't work and console shows 404 error for bundles.
It would be good to add an option to specify path for the bundled js files and index file.
+1 for this
Is there a way to split my chunk files in n different folders project wise?? I have multiple projects in single directory. After ng build I get 15 chunks. 5 belongs to each project. I want them to be in serparate folder in the name of the project. Is there a configuration that we can do in angular.json or using webpack and achieve this?? Please comment.
This will be very helpful if we have multiple projects in a single directory and we want to deploy only the specific project chunk files in the server.
Here is how I do that : in the file package.json, below the scripts node, I add a script called postbuild that will :
- Move the files in the dedicated folder (
resourcesin my example) - Search and replace
<script src="*.js"></script>inindex.htmlby<script src="resources/*.js"></script>. The search and replace is done withsedcommande line (please be aware that there are some difference withsedcommande line on linux or MacOS).
Here is the final look of my package.json file :
{
"name": "my-project",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"postbuild": "mv ./dist/my-project/*.js ./dist/my-project/*.js.map ./dist/my-project/resources; sed -i -e 's/src=\"/src=\"resources\\//g' dist/my-project/index.html",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
}
}
+1 for this. We need to be able to have Index.html in the root and scripts in a separate folder. One common case for this is when we integrate an angular application into a another web project, and that other web demands that the js files are stored in a separate folder.
@moussa-b 2. just put "deployUrl" in your angular.json
This work for me. Thanks
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.