Django-Bower + Foundation 5 + SASS,如何配置?

CSS

斯丁前端

2020-03-24

我正在使用Django-Bower测试Foundation 5的SASS实现。我对Bower的想法是陌生的,并且对如何使此设置正常工作感到有些困惑。

我已经安装了django-bower并将其配置为可以正常运行。将基础添加到Bower应用程序配置并运行后,manage.py bower_install我可以看到基础文件确实已正确安装。我还可以使用static标签将JS加载到模板中而不会出现问题,所以我感觉我已经快到一半了。

我的问题是关于如何实际使用随我的自定义SASS文件安装的bower的基础文件,以及将这些SASS文件编译为CSS的最佳方法。我知道我应该能够将基础包括在我的SASS中,@include "foundation"但是我对如何获取SASS文件以“查看” components / bower_components / foundation / sass中的基础文件以及如何进行设置一无所知将css放入正确的静态文件的编译。

更新:PyCharm有一个选项可以查看sass文件并进行编译,因此我现在可以选择编译文件,但是当我尝试导入基础时,我得到了 error blog3.sass (Line 1: File to import not found or unreadable: foundation.

供参考,这是我的文件结构:

├── blog3
│   └── __pycache__
├── components
│   └── bower_components
│       ├── foundation
│       │   ├── css
│       │   ├── js
│       │   │   ├── foundation
│       │   │   └── vendor
│       │   └── scss
│       │       └── foundation
│       │           └── components
│       ├── jquery
│       └── modernizr
│           ├── feature-detects
│           ├── media
│           └── test
│               ├── caniuse_files
│               ├── js
│               │   └── lib
│               └── qunit
└── interface
    ├── migrations
    │   └── __pycache__
    ├── __pycache__
    ├── sass
    └── templates
        └── interface

这是我的settings.py

"""
Django settings for blog3 project.

For more information on this file, see
https://docs.djangoproject.com/en/dev/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/dev/ref/settings/
"""

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__)) 


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/dev/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '...'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'annoying',
    'django_extensions',
    'djangobower',
    'interface',

)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'blog3.urls'

WSGI_APPLICATION = 'blog3.wsgi.application'


# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True  


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/dev/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_FINDERS = (
    'djangobower.finders.BowerFinder',
)

BOWER_COMPONENTS_ROOT = os.path.join(BASE_DIR, "components")
BOWER_INSTALLED_APPS = (
    'jquery',
    'foundation',
)

第3269篇《Django-Bower + Foundation 5 + SASS,如何配置?》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

0个回答

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android