CSS-Extended icon indicating copy to clipboard operation
CSS-Extended copied to clipboard

When the parameter "load_external_files" is empty, traverse the folder and look for all the files specified in "css_extension".

Open YaKazama opened this issue 6 years ago • 2 comments

When the parameter "load_external_files" is empty, traverse the folder and look for all the files specified in "css_extension".

Modify the file: project.py for the following(By default(implemented functionality, unaffected.), the css file in "link" is looked up in the HTML file.):

import sublime, glob, os

ST2 = int(sublime.version()) < 3000

if ST2:
    import settings
else:
    from . import settings


def get_all_files(path):
    files = []
    if not os.path.isdir(path):
        raise
    for x in os.listdir(path):
        f = os.path.join(path, x)
        if os.path.isdir(f):
            files.extend(get_all_files(f))
        else:
            files.append(f)
    return files


def get_external_files():
    _load_external_files = settings.get('load_external_files', [])
    _css_extension = settings.get('css_extension', [])
    external_files = []
    _tmp_files = []

    if _load_external_files == []:
        _load_external_files = sublime.active_window().folders()

        if _css_extension == []:
            _css_extension = ['.css', '.less', '.scss']

        for _dir in _load_external_files:
            _tmp_files.extend(get_all_files(_dir))

        for _x in _tmp_files:
            for _y in _css_extension:
                if _x.endswith(_y):
                    external_files.append(_x)
    else:
        for file_path in _load_external_files:
            external_files.extend(glob.glob(file_path))
    print(external_files)
    return external_files

YaKazama avatar Jan 21 '19 09:01 YaKazama

If you want to control whether all CSS files in the entire project are automatically processed when Sublime Text 3 starts, you can change the

_load_external_files == []

in the file project.py to:

_load_external_files == "auto"

and change the value of the parameter load_external_files to: auto, like this:

"load_external_files": "auto"

YaKazama avatar Jan 23 '19 02:01 YaKazama

I like this extension a lot but as I have several css files on the pages it locks up the sublime, it gets all the css files and lock it has to sort it?

wpixelweb avatar Apr 05 '19 17:04 wpixelweb