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

Compile multiple CSS files into different directories #103

Open
cdils opened this issue May 9, 2018 · 8 comments
Open

Compile multiple CSS files into different directories #103

cdils opened this issue May 9, 2018 · 8 comments

Comments

@cdils
Copy link
Contributor

cdils commented May 9, 2018

I'm in the process of adding editor-specific and gutenberg-specific styles to a project. While this is possible with the existing WPGulp styles task, I'd like to suggest a more elegant implementation.

Current output

In my project config.js file under Style Options, I have:

// Style options.
styleSRC: './develop/scss/*.scss', // Path to main .scss file.
styleDestination: './', // Path to place the compiled CSS file. Default set to root folder.

styleSRC points to three Sass files I have created:

editor-styles.scss // editor styles
gutenberg.scss Gutenberg-specific styles
styles.scss // main style sheet

Running these through the styles task produces these files in my project root:

|- editor-styles.css
|- editor-styles.min.css
|- editor-styles.css.map
|- gutenberg.css
|- gutenberg.min.css
|- gutenberg.css.map
|- styles.css
|- styles.min.css 
|- styles.css.map

Proposed output

That's a lot of clutter. I'd prefer to see something like this:

|- css/ 
|    |- editor-styles.css
|    |- editor-styles.min.css
|    |- gutenberg.css
|    |- gutenberg.min.css
|- styles.css
|- styles.min.css 
|- styles.css.map

It's debatable whether or not a CSS map for editor and Gutenberg styles is that useful, since those are presumably quite small files and easy to troubleshoot. It's also debatable whether you'd want to keep the three main style sheet variations in the root or move everything off to a css folder, save for styles.min.css.

Possible solution

There are multiple approaches to this. One is to add a couple of variables to config.js such as styleSRCHelpers and styleDestinationHelpers and use that as the basis for a new gulp task that mimics the current styles task, but skips sourcemap creation and routes "helper" css files (for editor and gutenberg) to a different location (i.e. css/ folder).

Forgive me, my brain isn't creative enough for better thoughts on names at the moment!

Feedback wanted

Ultimately, I'd like feedback on:

  1. Whether there's a use-case to even justify adding something like this to WPGulp versus me just implementing a one-off solution in my project. My gut is that with Gutenberg coming, there's a good use-case for generating Gutenberg-specific stylesheets and wanting to store those somewhere other than the project root. Gutenberg aside, I think there's also a use-case for needing to compile specific Sass files to specific folders. For example, if I needed to create custom styles to extend Easy Digital Downloads, I'd need to compile those Sass files into an EDD-specific folder. For reference, here's how compiling multiple CSS files was done in wp-gulp-toolkit.

  2. Thoughts on implementation. The solution I mentioned above is just one idea. Whatever solution is involved would need to also consider how/if generating corresponding rtl files is necessary.

If this is something that would be worthwhile for WP Gulp, I'm happy to investigate further, but would appreciate some input.

@ahmadawais
Copy link
Owner

Apologies, I've been away due to a family emergency. Will respond soon. Nice ideas.

@cdils
Copy link
Contributor Author

cdils commented May 23, 2018

No worries @ahmadawais

@ahmadawais
Copy link
Owner

@cdils now that v2 has been released how do you propose we can handle this?

@Suzakura
Copy link

I also want this feature.
When will it be adopted in the official version?

Repository owner deleted a comment from hegemanjr May 15, 2019
Repository owner deleted a comment from iamgaby7521 May 15, 2019
@isvictorious
Copy link

I see an approved PR for this in #125 - how can we get it merged?

@jamieschmid
Copy link

Pinging this! I just duplicated style-RTL to generate basically the same files as @cdils although not very elegantly. Are there any roadblocks on this merge, I'd love to try it out!

@ahmadawais
Copy link
Owner

None beyond time. If you can test this and review the PR it will help.

@AndreaBarghigiani
Copy link

I've tested this PR and for me is it working like a charm! Thanks @mintbird for your work!

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

No branches or pull requests

6 participants