-
-
Notifications
You must be signed in to change notification settings - Fork 199
Unable to add custom options for sass compilation #14
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
Comments
+1 This will be easy, we just need to find an API we like :). The The tricky part is finding a good API for these 2 ideas:
.enableSassLoader(function(loaderOptions) {
// this is our special option
loaderOptions.resolve_url_loader = true,
// this is an option to be passed to sass-loader
loaderOptions.includePaths = [...]
}); I've refactored this into a callback (instead of just passing a hash) because - so far- we're avoiding situations where we might need to "merge" user config and default config (see #15 (comment)).
.enableSassLoader(function(config) {
// this is our special option
config.disableResolveUrlLoader();
// this is an option to be passed to sass-loader
config.loaderOptions.includePaths = [...]
}); |
How about making this function work with variadic arguments. Where we would have an object where we store the proxy config used by encore and a callback that gets the generated options passed as an argument. That way you could modify the generated options as needed. Example I : Setting only config .enableSassLoader({ resolve_url_loader: false }); Example II : Setting only options .enableSassLoader(function(options) {
// add or set custom options
options.includePaths: ["absolute/path/a", "absolute/path/b"];
}); Example III : Setting both config and options .enableSassLoader({ resolve_url_loader: false },function(options) {
// add or set custom options
options.includePaths: ["absolute/path/a", "absolute/path/b"];
}); Example IV : Setting both config and options alternatively .enableSassLoader(function(options) {
// add or set custom options
options.includePaths: ["absolute/path/a", "absolute/path/b"];
},{ resolve_url_loader: false }); |
@DaRamirezSoto Sorry for the delay - I was pushing through a few other things first :). My vote is to combine the config. Basically, we would say something like:
I think this is pretty clear and I don't see any technical disadvantage to combining them. The solutions that keep them separated (which you laid out clearly) are really ugly. And to stay consistent with #49 and #50, I think we should use a callback. So.... it would be an option V ;) .enableSassLoader(function(options) {
// add or set custom options
options.includePaths: ["absolute/path/a", "absolute/path/b"];
// set our custom option
options.resolve_url_loader = false;
}); |
@weaverryan I am really confused now. There is going to be some confusing in regards to the file name used. People seeing The solution change the file name to I understand that there is a need for a |
Hi @DaRamirezSoto,
That is the part where you hit what an opinionated solution can/can not do. Encore has an opinionated solution regarding Honestly I don't see a better way to deal with that, at least if you want to allow people to be able to configure all aspects of the loader freely (not so opinionated). You need to do it passing missing options, through an A compromise should be made. In this case,
with
I found more value on lastest since it is explicit as a callback parameter. For the object syntax one would need to know that configuration is split, being more error prone since most of the time you will end up always looking how is the format of that object you want to write for configure all things you want. Was it Also regarding hope it helps. |
Hi @davidmpaz To me, it made more sense to separate encore options from pass-through options used for the loaders. Your comment made me realize that I find Webpack already pretty opinionated and maybe troubled about using/ setting up more opinions on top of it and losing, even more, flexibility and interoperability Therefore encore might be not the right tool for me. Thank you for your response. |
Sad to hear that @DaRamirezSoto :( ... Please notice that you can always opt out to not use some features. Later (after exporting configuration from encore) any setup can be added as normal webpack options. Currently that's is what I do right now since for me it is not a complete fit also. |
Hmm @DaRamirezSoto, then what about an option that's very similar to your option III: .enableSassLoader(function(options) {
// add or set custom options
options.includePaths: ["absolute/path/a", "absolute/path/b"];
}, { resolve_url_loader: false }); I've just reversed the first and second argument for consistency with other loaders, where we would consistently have an options callback as the first argument (and sometimes we would have a second argument for Encore-specific stuff when needed - so far, this is only for the sass-loader).
Please try to keep things positive and respectful :). I do appreciate your help and thoughts, but I don't want anyone in the Symfony community (myself included) to feel insulted for their ideas. @davidmpaz About your example with the |
yes; would be a better solution IMO.
Was not aware I was being unrespectful or negative just a spicy discussion in a similar fashion as you did ( see below ) but of course, I agree I am all for positivity and respect.
I tried this and did not like it. Mainly because configuration would get so fragmented so maintaining it would become harder. If you are working alone on project maybe not such a problem, but when working with a team not something you should do I think, |
@DaRamirezSoto Ah, you're right! I realize my comment also wasn't respectful - my apologies :). Unless someone beats me to it (which would be awesome), I'll open a PR soon for the version I mentioned above (#14 (comment)). |
PR #76 |
This PR was merged into the master branch. Discussion ---------- Adding ability to pass options to sass-loader Fixes #14 This is a BC break, which I want to minimize. But, since we're pre 1.0, BC breaks are allowed. And this will fail clearly the first time you try to run encore. Docs: symfony/symfony-docs#8108 Commits ------- f803b9a Adding ability to pass options to sass-loader
When trying to use foundation I ran in to problem where I have to add custom include paths.
Adding them as options is not working as only
resolve_url_loader
is a valid option.The text was updated successfully, but these errors were encountered: