Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
YaKazama opened this issue Jan 21, 2019 · 2 comments

Comments

@YaKazama
Copy link

YaKazama commented Jan 21, 2019

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
Copy link
Author

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"

@wpixelweb
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants