Coder Social home page Coder Social logo

Comments (4)

ryansully avatar ryansully commented on August 19, 2024

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.

miracle2k avatar miracle2k commented on August 19, 2024

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.

ryansully avatar ryansully commented on August 19, 2024
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.

miracle2k avatar miracle2k commented on August 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.