-
-
Notifications
You must be signed in to change notification settings - Fork 210
Support global config with load config package #97
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
Support global config with load config package #97
Conversation
Great! Fast work :). Sorry, I could review it only tomorrow (I am not so fast :( ) |
Awesome! Please keep in mind that I've just started and submitted PR already because it will not be one liner and any tip on this stage can prevent a headache later on :) |
Looks good. Only few very small things:
|
From what I see it may be tricky to support pack feature when config loader is used. Are you ok with having it only for the current behavior? |
Feel free to return error on using pack with config |
5e4f709
to
71943ce
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still some things to improve
9a90364
to
29e279f
Compare
@ai I think it's done more or less. I've tried to utilize I've added more tests and they require separate configs, so we have multiple gulp tasks generated per each config scenario. What do you think about it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self-review done, ready for the final review
Great work, I will review it tomorrow (sorry, working day was started) |
Looks good. Sorry, it could take a while (need be sure, that it will help in webpack 2 too) |
29e279f
to
93b7003
Compare
New webpack 2 issue bring new question. Could we do everything with this config? How we could cover |
I don't think so we can cover |
@ertrzyiks do we have any way to pass If not, we could ask @michael-ciniawsky for some solution |
@ai we could do this but by breaking the whole idea of having config object with primitive values (as it requires a config value being a function). Maybe @michael-ciniawsky can come up with some idea. I'm wondering if it would be possible to feed postcss with webpack instance and use internal pub-sub communication (if any) between postcss and plugins to propagate it. |
Hm. Maybe we could use @ertrzyiks sorry for delay, it is very big API changes, let’s think twice to avoid haters to hate :D |
@swernerx @MoOx @TrySound @borodean what do you think if all import plugin should set absolute path for all used resources to use it then in webpack? result.messages.push({ type: 'dependency', path: '/home/ai/test/images/logo.png' }) As result hot reload will work out-of-box in postcss-loader, without painful config. |
@ai that should be fine for postcss-assets, however, I'd need someone's help implementing this. |
@ai IMHO this seems to be a good idea. Makes it far easier to track paths from different "viewpoints" and unify them. |
Since import plugins are used first, there is no need to put all resources, because the work will be done by webpack when css is inlined by the plugin. So maybe ok for the path, but no need for all resources. Anyway, for postcss-import, there is a total mess to handle. @TrySound made some huge changes and never really finished the job, so there are tons of issues related to race conditions... But current algorithm looks to complicated for my brain, and I am busy with new projects, so no time to handle this... That's why I called for contributor for postcss-import, but, as usual, not a single person responded. |
Finally merged. Thanks, great work. I just need to update docs, add |
Sponsor badge directly under the logo or is the sponors section at the bottom ok aswell? postcss-load-config supports passing a function now, finishing the eval stuff and test it with especially this loader, if it does what it is supposed to be :). @ai can you give me an example/explanation ( little more in-depth :) ) of how the |
@michael-ciniawsky great work! Few moments:
I could pull your changes and fix all this list tomorrow (you did a lot with config loader) :). |
Hm, by the way, maybe somebody want to take maintaining for this loader? It is not hard. But I ma not webpack user at all. You showed great productivity and good understanding of webpack. I think project will be better if maintainer could at least test it on work project :D. |
I can do and would liveto do it, but secondary chore work :)
I can do it, already maintaining html-loader, posthtml-loader. webpack org peasant member :D Send invite and grant access here, I can also transfer the load-* stuff then and update it at the weekend, to finally move out of alpha, beta. It makes things a lot easier for me (update it to v1.0.0 asap, add jsdoc, keep track of webpack 2 beta etc.) |
👍 But transfering the postcss-load-* repos doesn't work, should the stay at my github? |
@michael-ciniawsky yeap, you could keep it :) If you want to move them to |
@ai Can some the content related ajustments stay?
kk |
@michael-ciniawsky what exactly “content related ajustments”? I like that you split webpack 1 and webpack 2. But maybe we should promote your config first?
|
@michael-ciniawsky I pulled docs changes, thanks. |
@ai so you want to push them later? I'm asking because otherwise I will do it today, during the day with postcss-load-config release? :) It's neglectible, adding the postcss.config.js example later, just don't want to mess things up here |
I wrk polish docs today 😊👍 |
👍 |
I finished all changes and ready for release. Could somebody test this plugin on real application? (Just replace version in |
@ai I get a webpack validation error when using the following config:
I think Webpack 2 expects loaders to nest options like this, e.g.
webpack: 2.1.0-beta.25 |
@richardscarrott yep, i was wondering about that too, your example with {
loader: 'postcss-loader'
options: {
plugins: () => [ require('autoprefixer') ]
}
} is the correct one, but to my knowledge, it's currently not possible to use a function inside const { LoaderOptionsPlugin } = require('webpack')
const config = {
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', {loader: 'css-loader', options: { importLoaders: 1 }}, 'postcss-loader']
}
],
plugins : [
new LoaderOptionsPlugin({
options: {
postcss: () => {
return [ require('autoprefixer') ]
}
}
})
]
}
module.exports = config I check the webpack slack quickly, just one moment please :) |
@richardscarrott @michael-ciniawsky fix for webpack 2 config example: e6351b8 Is it correct? |
@michael-ciniawsky yeah I just noticed it does work with Looks like your LoaderOptionsPlugin workaround is the best approach or I guess create a separate postcss.config.js. @ai I can't find that commit? |
@richardscarrott kk, I will check that |
Oops, it was merge confict :D. Fixed. |
@ai basically yes, currently nope 😛 , and combined with {
loader: 'postcss-loader'
options: {
plugins: () => [...plugins] // Error
}
} !== {
loader: 'postcss-loader'
options: () => { parser: sugarss, plugins: [...plugins] }
// According to @sokra this should be possible since webpack v2.1.0-beta.25,
// when ['loader-utils'].parseQuery(loader.query) is used as it currently is in postcss-loader
// but API Schema complains that typeof module.rules[1].use[2].options === 'string' || 'options'
// always fun, fun... , fun...... :D
} But there seems to be an issue with parseOptions in postcss-loader in general webpack.config.js {
loader: 'postcss-loader',
options: {
plugins: () => [ require('postcss-nested') ]
}
} postcss-loader/index.js var params = loaderUtils.parseQuery(loader.query)
console.log(params)
// => {} params.plugins stripped 2. {
loader: 'postcss-loader',
options: {
parser: 'sugarss',
plugins: () => [ require('postcss-nested') ]
}
} postcss-loader/index.js var params = loaderUtils.parseQuery(loader.query)
console.log(params)
// => { parser: 'sugarss' } params.plugins stripped 3. {
loader: 'postcss-loader',
options: {
parser: 'sugarss',
plugins: [ require('postcss-nested') ]
}
} postcss-loader/index.js var params = loaderUtils.parseQuery(loader.query)
console.log(params)
// => { parser: 'sugarss' plugins: [ null ] } params.plugins not loaded |
@MoOx @michael-ciniawsky so in practice webpack anyway strip functions from options? So, should we remove |
Webpack 2 remove this restriction. You can pass anything in query now. |
@mood it is great. But @michael-ciniawsky shows different 😕. Do we have any mistakes? Maybe we should replace |
I made a test case: https://github.com/ai/webpack2-postcss-test
|
It's written in https://github.com/webpack/webpack/releases/tag/v2.1.0-beta.23 |
It's going to address #88 , but it may require more attention in the early phase. Any feedback is welcome.