Arun Raj R
Arun Raj R

Reputation: 2317

How to bundle asset folder in angular4 app?

I am using Angular4 App with Webpack. When I build the application using ng-build --prod command, the assets folder is coming in the dist folder. But, the css & js files are not in the bundled or minified form.

I would like to know how to bundle & minify the js & css files in my assets folder?

Upvotes: 1

Views: 1556

Answers (1)

alfredson
alfredson

Reputation: 241

I guess your js and css files in the assets folder are external dependencies.

You can add these in the .angular-cli.json file. They will will be compiled automatically in the scripts.bundle.js for Javscript respectively in the styles.bundle.js for CSS.

Go to .angular-cli.json and add for Javascript:

"scripts": [
     "path/to/your/js/file"
],

and for CSS files:

"styles": [
     "path/to/your/css/file"
],

You should not add external dependencies to the assets folder.

Regards

Upvotes: 1

Related Questions