-
-
Notifications
You must be signed in to change notification settings - Fork 212
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
Plugins could not be passed through options in webpack 2.2.0 #164
Comments
now we have to use ident key in options to pass function |
@TheLarkInn I need you help here. Do we need to change our current docs? |
@ai @artemkaint Same issue, seems like |
@maratfakhreev @artemkaint please show your full configs. In most previous cases it was not a PostCSS loader problem, but Extract Text plugin or other crazy thing. |
@ai yeah, thx, have found the problem on my side. Loader works correctly. |
@ai I work on new docs for inline config already, but I'm waiting for reply if 'this' (@example) will stay or not because I absolutely don't like it 😛 => {
loader: 'postcss-loader',
options: { ident: 'postcss', plugins: () => [ require('plugin') ] }
} README (WIP) @ai I push (PR) them as quickly as possible, should I in addition push just the example fixes asap? I also wanted to add an example for |
@ai @artemkaint @maratfakhreev guys please a on webpack/webpack#4073 to get rid of |
I commented a summary of possible ways to resolve this on another (closed) issue. Here is my comment: So basically, what I conclude after reading and some researching, there are 4 ways (as for now) to load the PostCSS configuration for Webpack 2:
As a side note, since this depends mainly on cosmiconfig we also have other 3 ways here:
{
loader: 'postcss-loader',
options: {
ident: 'postcss', // <- This..
plugins: () => [ require('plugin') ]
}
}
The last 2 are handled respectively by this line of code: Hope this helps someone else (avoiding possible headaches) in the future. EDIT: Update as for Webpack
|
Works for me with webpack 2.2.1: {
test: /\.scss$/,
use: [
...,
{
loader: 'postcss-loader',
options: {
plugins: () => [ require('autoprefixer')({ browsers: ['last 2 versions'] }) ]
}
},
...
]
} |
@vladshcherbin You where faster 😛 As a note for anyone coming here using an older webpack || extract-text-plugin version =>
webpack.config.js import ExtractText from 'extract-text-webpack-plugin'
export default {
module: {
rules: [
{
test: /\.css$/,
include: 'path/to/includes', // optional
exclude: 'path/to/excludes', // optional
use: [
'style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
{
loader: 'postcss-loader',
options: { plugins: (ctx) => [ require('plugin')({ option: ctx.resourcePath }) ] }
}
]
},
// Extract Text Plugin
{
test: /\.css$/,
include: 'path/to/includes', // optional
exclude: 'path/to/excludes', // optional
use: ExtractText.extract({
fallback: 'style-loader'
use: [
{ loader: 'css-loader', options: { importLoaders: 1 } },
{
loader: 'postcss-loader',
options: { plugins: (ctx) => [ require('plugin')({ option: ctx.resourcePath }) ] }
}
]
})
}
]
},
plugins: [
new ExtractText([name].css)
]
} Closed as fixed :) |
If I use the constraction from the example
I have obtain
/opt/project/node_modules/postcss-loader/index.js?{"plugins":{"default":[null,null],"fontAwesome":[null,null]},"pack":"default"}
https://github.com/webpack/webpack/blob/master/lib/NormalModuleFactory.js#L21
Beсause all function have been converted into string (of course null)
The text was updated successfully, but these errors were encountered: