Upon building & packaging an Angular 6 library, I can\'t seem to be able to instruct the Angular CLI to copy the library\'s assets into the dist/assets fold
Currently, I still have not found an official built-in way to do so.
I opened an Angular CLI issue and hopefully will get the CLI team response.
In the meantime my workaround is using command line tools:
In package.json I added:
"scripts": {
...
"build": "ng build lib1 --prod && scss-bundle -c scss-bundle.config.json && cp -R projects/lib1/src/assets/ dist/lib1/assets/",
}
To copy the SASS files I use scss-bundle with config file scss-bundle.config.json that contains:
{
"entry": "./projects/lib1/src/assets/style/main.scss",
"dest": "./dist/lib1/assets/style/styles.scss"
}
This will build the SASS files of the project into 1 file and copy it into the dist folder. My SASS file structure is something like:
-- projects/lib1/src/assets/
-- style
-- main.scss
-- partials
-- _variables.scss
-- _styles.scss
__ _rtl.scss
So as you can see I don't want to ship all the raw sass, just one final file. Of course, you can also compile it into a .css file instead.
To make sure all other assets are copied, I use a simple Mac OS/Linux command cp -R or rsync.
And, of course, instead of running ng build I run npm run build.
Hope this helps, and if you have a better solution please let me know.