使用Django Compressor和Django Sass处理器时出现的“sass.CompileError:错误:不清楚导入哪个文件”

时间:2018-04-12 00:53:15

标签: django sass django-compressor

我正在尝试将Materialise源添加到Django项目中。在我的WiFi.config(ip,gateway,subnet); WiFi.mode(WIFI_STA); Serial.print("Attempting to connect to SSID: "); Serial.println(WIFI_SSID); // Connect to WPA/WPA2 network. Change this line if using open or WEP network: WiFi.begin(WIFI_SSID, WIFI_PASSWORD); while (WiFi.status() != WL_CONNECTED) { Serial.print("."); delay(500); } Serial.print("connected."); 目录中,我有以下结构:

stylesheets

http://materializecss.com/getting-started.html提供的源版本下载(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ tree lucy-web/lucy_web/static/stylesheets lucy-web/lucy_web/static/stylesheets ├── mixins.scss ├── terms_of_use.scss └── vendor ├── components │   ├── _badges.scss │   ├── _buttons.scss │   ├── _cards.scss │   ├── _carousel.scss │   ├── _chips.scss │   ├── _collapsible.scss │   ├── _color-classes.scss │   ├── _color-variables.scss │   ├── _datepicker.scss │   ├── _dropdown.scss │   ├── _global.scss │   ├── _grid.scss │   ├── _icons-material-design.scss │   ├── _materialbox.scss │   ├── _modal.scss │   ├── _navbar.scss │   ├── _normalize.scss │   ├── _preloader.scss │   ├── _pulse.scss │   ├── _sidenav.scss │   ├── _slider.scss │   ├── _table_of_contents.scss │   ├── _tabs.scss │   ├── _tapTarget.scss │   ├── _timepicker.scss │   ├── _toast.scss │   ├── _tooltip.scss │   ├── _transitions.scss │   ├── _typography.scss │   ├── _variables.scss │   ├── _waves.scss │   └── forms │   ├── _checkboxes.scss │   ├── _file-input.scss │   ├── _forms.scss │   ├── _input-fields.scss │   ├── _radio-buttons.scss │   ├── _range.scss │   ├── _select.scss │   └── _switches.scss ├── materialize_v1.scss materialize_v1.scss;我已将components重命名为materialize.scss,以避免与旧版本发生名称冲突。

materialize_v1.scss中,我按如下方式导入terms_of_use.scss

materialize

在模板中,我使用@import "vendor/materialize_v1"; // Materialize v1.0.0beta compress标签,如下所示:

sass_src

在开发模式的本地计算机上(使用{% load compress %} {% load sass_tags %} <html> <head> {% compress css %} <link href="{% sass_src 'stylesheets/vendor/materialize_v1.scss' %}" rel="stylesheet" type="text/css" /> <link href="{% sass_src 'stylesheets/terms_of_use.scss' %}" rel="stylesheet" type="text/css" /> {% endcompress %} ),一切似乎都正常。但是,当我尝试部署到Heroku时,我收到以下错误:

DEBUG = True

似乎compilescss命令首先将(venv) Kurts-MacBook-Pro-2:lucy kurtpeek$ git push staging `git subtree split --prefix lucy-web terms-of-service`:master --force cache for 09dc1ce7e3b490f30ceeabbca0c9375e2013b596 already exists! Counting objects: 4188, done. Delta compression using up to 8 threads. Compressing objects: 100% (1430/1430), done. Writing objects: 100% (4188/4188), 1.22 MiB | 938.00 KiB/s, done. Total 4188 (delta 3084), reused 3590 (delta 2687) remote: Compressing source files... done. remote: Building source: remote: remote: -----> Python app detected remote: -----> Installing requirements with pip remote: Obtaining django_airbrake from git+https://github.com/airbrake/airbrake-django.git@02b0b422c6cdc8d5727bd6ea045bfdc362b380cd#egg=django_airbrake (from -r /tmp/build_64226978df3aac094d9ae50e59da9e58/requirements.txt (line 9)) remote: Cloning https://github.com/airbrake/airbrake-django.git (to 02b0b422c6cdc8d5727bd6ea045bfdc362b380cd) to /app/.heroku/src/django-airbrake remote: Could not find a tag or branch '02b0b422c6cdc8d5727bd6ea045bfdc362b380cd', assuming commit. remote: Installing collected packages: django-airbrake remote: Found existing installation: django-airbrake 0.0.2 remote: Running setup.py develop for django-airbrake remote: Successfully installed django-airbrake remote: remote: -----> Running post-compile hook remote: -----> $ python manage.py compilescss remote: ................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................Traceback (most recent call last): remote: File "manage.py", line 29, in <module> remote: execute_from_command_line(sys.argv) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line remote: utility.execute() remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute remote: self.fetch_command(subcommand).run_from_argv(self.argv) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv remote: self.execute(*args, **cmd_options) remote: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute remote: output = self.handle(*args, **options) remote: File "/app/.heroku/python/lib/python3.6/site-packages/sass_processor/management/commands/compilescss.py", line 160, in handle remote: self.parse_template(template_name) remote: File "/app/.heroku/python/lib/python3.6/site-packages/sass_processor/management/commands/compilescss.py", line 271, in parse_template remote: self.compile_sass(sass_filename, node.path) remote: File "/app/.heroku/python/lib/python3.6/site-packages/sass_processor/management/commands/compilescss.py", line 289, in compile_sass remote: content = sass.compile(**compile_kwargs) remote: File "/app/.heroku/python/lib/python3.6/site-packages/sass.py", line 640, in compile remote: raise CompileError(v) remote: sass.CompileError: Error: It's not clear which file to import for '@import "vendor/materialize_v1"'. remote: Candidates: remote: vendor/materialize_v1.scss remote: vendor/materialize_v1.css remote: Please delete or rename all but one of these files. remote: on line 1 of lucy_web/static/stylesheets/terms_of_use.scss remote: >> @import "vendor/materialize_v1"; // Materialize v1.0.0beta remote: ^ remote: remote: remote: ! Error while running '$ python manage.py compilescss'. remote: See traceback above for details. remote: remote: ! Push rejected, failed to compile Python app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to lucy-staging. remote: To https://git.heroku.com/lucy-staging.git ! [remote rejected] 34560aaa9267f49d1e6042390e203efe9d275def -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/lucy-staging.git' 编译为materialize_v1.scss,然后在我materialize_v1.css @import时我的意思变得模棱两可}。

这听起来像是发生了什么吗?我该怎样做才能消除歧义?

1 个答案:

答案 0 :(得分:1)

您应该将myapp$ pm2 start bin/www --watch /your/location/to/app 重命名为vendor/materialize_v1.scss。这可以防止编译要包含在其他scss文件中的文件。

此外,从HTML引用vendor/_materialize_v1.scss以及稍后将该文件再次包含在vendor/materialize_v1.scss中是没有意义的。因此,最好的方法是删除HTML中的第一个引用,即。 stylesheets/terms_of_use.scss并完全依赖于<link href="{% sass_src 'stylesheets/vendor/materialize_v1.scss' %}" rel="stylesheet" type="text/css" />中的@import语句。