Comments (4)
I first noticed this issue when applying debug=False
to a compiled CSS bundle, applying compression and data URI filters intended for production further up while registering the bundle, and noticing that all filters were being applied in debug mode instead of just the compiled CSS filter.
I came up with a nasty workaround in the meantime: include an empty CSS file at a bundle level just above the compiled CSS bundle, at the same level as or before applying other filters. Somehow this causes only the compiled CSS bundle to be filtered/compiled, while not applying other filters.
Of course this isn't optimal, requiring an empty/dummy CSS file to be created and referenced everywhere you want to isolate the compiled CSS filter from other CSS filters, as well as adding extra unnecessary overhead during an assets build. Hopefully this provides an idea or motivation for a more permanent solution.
from webassets.
Interesting. That's actually a separate problem, but I see what it is. These outer bundles which only define filters but no content or output are not "built" directly, but only push their filters down to the nested ones (I call them container bundles).
Still, I would love to see an code snippet as an example of your configuration, to ensure I'm understanding correctly.
from webassets.
scss_bundle = Bundle('scss/styles1.scss',
'scss/styles2.scss',
filters='pyscss', debug=False,
output='gen/scss/styles.css')
This will compile with compression and data URIs:
css_compressed_bundle = Bundle(scss_bundle,
filters='yui_css,datauri',
output='gen/css/compressed_bundle.css')
This will only compile SCSS, without compression and data URIs:
css_compiled_only_bundle = Bundle(scss_bundle,
'css/empty.css', # empty css file
filters='yui_css,datauri',
output='gen/css/compiled_only_bundle.css')
Note that everything works as intended when environment.debug == False
, this issue only occurs when debug == True
.
from webassets.
Ryan, I can't reproduce this now (https://gist.github.com/2835601 works for me), but the build code did receive some modifications recently, so maybe this was fixed by accident. Still, allow me to add two notes:
-
You cannot test such a thing by calling bundle.build() while environment.debug=True; it would just pretend that debug=False, because build() with debug=True makes no sense. Instead, bundle.urls() needs to be used for testing.
-
Using recent master, you can do
scss_bundle = Bundle('scss/*.scss',
filters='pyscss,yui_css,datauri', output='gen/css/compiled.css')without needing a nested bundle at all, so this should also obsolete the empty.css workaround.
from webassets.
Related Issues (20)
- jsmin/rjsmin removes blanks in ES6 Template Strings HOT 1
- Fail when packing an external resource HOT 4
- YAMLLoadWarning yaml.load is deprecated
- Bundles cannot be replaced/re-added
- --line-comments is deprecated
- LibSASS - Unable to use other compile options like source_comments
- Version 2: Couldn't find preset HOT 3
- Threading.isAlive was removed in Python 3.9
- Load_builtin_filters doesn't work as expected with PyInstaller
- Deprecation warning due to invalid escape sequences in Python 3.7
- Fix simple typo: ultimatily -> ultimately
- Closure: ReferenceError: $jscomp is not defined
- Copy assets
- SCSS filter runs command sass without --scss HOT 2
- Add a tool to remove unused css
- How to configure filters using the YAML config option? Specifically cssrewrite. HOT 1
- Jinja2 Base template loaded twice when upgrading werkzeug package
- Add a way to get all bundle names
- 'out' is deprecated and will stop functioning in TypeScript 5.5
- mode merge=False not implemented in flask_assets
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webassets.