How to pass filter specific configuration options

2019-07-24 01:43发布

Using , , I am trying to pass a filter specific configuration for a particular filter in webassets, but haven't been able to do so, so far.

Have read the documentation multiple times to no avail. Have also gone through the source code, but that hasn't helped either.

Specifics:

  • The filter I'm trying to use is cleancss
  • And the particular configuration I'm trying to pass is --skip-rebase

According to the link to cleancss docs above, I should be able to pass the --skip-rebase option in CLEANCSS_EXTRA_ARGS. But where do I put that?

What I've tried so far, passing as flask config variables:

CLEANCSS_EXTRA_ARGS = ['--skip-rebase']  # actually works, see answer!
CLEANCSS_EXTRA_ARGS = ['skip-rebase']  # doesn't work!
ASSETS_CLEANCSS_EXTRA_ARGS = ['--skip-rebase']  # doesn't work!
FLASK_ASSETS_CLEANCSS_EXTRA_ARGS = ['--skip-rebase']  # doesn't work!
ASSETS_CLEANCSS_EXTRA_ARGS = ['skip-rebase']  # doesn't work!
FLASK_ASSETS_CLEANCSS_EXTRA_ARGS = ['skip-rebase']  # doesn't work!

ps: I also tried modifying the source to check if cleancss parameters are being correctly passed to the command line, and it is, so the problem is only in specifying the option correctly in the app configuration.

1条回答
孤傲高冷的网名
2楼-- · 2019-07-24 01:59

On retrying with the first option in question:

CLEANCSS_EXTRA_ARGS = ['--skip-rebase']

It worked!

More info available in the flask assets repo issues.

In my hurry I must have tried with:

CLEANCSS_EXTRA_ARGS = ['skip-rebase']

which didn't work and hence the question.


This feature should be documented though. Will probably submit a pull request for doc improvement.


Also note that this requires version 0.11 (webassets) and above.

查看更多
登录 后发表回答