I'm trying to consolidate all the random things we do in our project to make things work. This SO question is about copying image files and fonts from their node_modules source to the right location in our flask application.
After a great deal of reading the docs and searching around, we cannot find a way to do this with Flask Assets. Hence, this question.
In our project, our designers create fonts and images and save them into nodejs packages. Our developers then consume the packages as-is with no need to perform any additional manipulation such as image crunching.
Is there a way to copy assets, without consolidating/filtering them using flask-assets
or webassets
?
Given:
/my-app
/app
/static
/js
/css
bundle.py
__init__.py
/assets
/js
my-module.js
/css
my-modules.css
/node_modules
/my-library
/scss
my-library.scss
/js
my-library.js
/img
logo.png
/my-module
/my-module-logo.png
/fonts
font1.ttf
where bundle.py contains:
from flask_assets import Bundle
bundles = {
'my_module_css': Bundle(
'../../node_modules/my-library/scss/my-library.scss',
'../../assets/css/my-module.scss',
filters='rjsmin',
output="css/my-module.min.css"
),
'my_module_js': Bundle(
'../../assets/js/my-module.js',
filters='jinja2, rjsmin',
output="js/my-module.min.js"
),
}
When this compiles, we get:
/my-app
/app
/static
/js
my-module.min.js
/css
/my-module.min.css
bundle.py
__init__.py
/assets
/js
my-module.js
/css
my-modules.css
/node_modules
/my-library
/scss
my-library.scss
/js
my-library.js
/img
logo.png
/my-module
/my-module-logo.png
/fonts
font1.ttf
The problem is that my-library
has an /img
and a /fonts
folder. I would like to copy that to app/static/img
and app/static/fonts
.
Is there a way to do this with flask-assets
or webassets
? Currently, we use a makefile to handle copying the images and fonts.