-
-
Notifications
You must be signed in to change notification settings - Fork 209
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
Incompatible with Webpack 2.1.0-beta.23 configuration validation #99
Comments
I will start this feature after we will stabilize config #97 |
Would this work as an ad-hoc fix? webpack/webpack#2974 (comment) |
@donaldpipowitch I am also curious. Would using this approach enable us use postCSS on the latest beta? |
Same issue +1 |
See webpack/webpack#3018 (comment) for a temporary workaround, which should work without a fix in |
So, are the Webpack options for postcss or the postcss-plugins? e.g. postcss()
.use(smartImport({
path: ["src/css"],
transform: require("css-whitespace")
}))
.process(cssString)
.then(function (result) {
var css = result.css
}) |
We must implement this asap. I can handle it, this change is required for me to cut a release for phenomic which require webpack 2. |
Problem is, the workaround mentionned earlier is not working if you use css modules. @ai poke me when you are ready to more forward, this is a small "big deal" we have to handle here :D |
@MoOx do we have any webpack 2 loader API changelog? What changes do you suggest? |
Changelog is: you can't rely on "random" properties in webpack global config. tl;dr: no more this.options.postcss and everything should be in For backward compat we can refactor the code and simply read options like this const options = {
...{ some default ? },
...this.options.postcss, // backward compat with v1
...loaderUtils.parseQuery(this.query)
} It's what I am doing for eslint-loader and it's working like a charm https://github.com/MoOx/eslint-loader/blob/f965eecfd5dac6489abeaebeb8fc7e5fa010bade/index.js#L128-L136 |
Validation succeeds for me: plugins: [
new webpack.LoaderOptionsPlugin({
options: {
context: __dirname,
postcss: [
autoprefixer
]
}
}
] Where const autoprefixer = require('autoprefixer'); See more at webpack/webpack#3018 (comment) |
@Oopscurity Can you not use |
You can use it, by passing the function as you used too. |
So it beta 25 the stable one now? |
@Oopscurity: I was having an issue with extract-loader as well because it couldn't find the |
Following up on: #99 (comment) Before, there was this method: // dependencies
var fs = require("fs")
var postcss = require("postcss")
var customProperties = require("postcss-custom-properties")
// css to be processed
var css = fs.readFileSync("input.css", "utf8")
// process css using postcss-custom-properties
var output = postcss()
.use(customProperties())
.process(css)
.css but now the API has changed. webpack config new webpack.LoaderOptionsPlugin({
options: {
postcss: function (webpack) {
return [
importCSS({
addDependencyTo: webpack
}),
customProperties({
preserve: true,
appendVariables: true,
}),
cssApply,
autoprefixer,
]
}
}
}), Directory structure
Yet I still get warnings the custom properties as used without fallbacks, unless I That solves one problem, but then introduces another: I've noticed that there are multiple style tags too, but I'm not sure why that's happening. With this new API, I'm not sure which file should be imported where and when, etc. |
@kevinSuttle This have NOTHING to do with how postcss-loader works, or webpack 2 update. This is why you have a way to define variables directly from your customProperties config. See readme of postcss-custom-properties. |
Fix by #104 Now we have |
I finished all changes and ready for release. Could somebody test this plugin on real application? (Just replace version in |
I can, but I don't see a newer version than 0.13.0 (the one I have now)? |
@kevinSuttle, as @ai said, you need replace
|
Er, I thought it worked with
My config: module.exports = {
entry: ['./src/'],
resolve: {
descriptionFiles: ["package.json"],
},
output: {
filename: 'ui-primitives-react.js',
path: path.resolve(__dirname, 'build'),
library: 'WatsonIoTUIPrimitives',
libraryTarget: 'commonjs2',
},
externals: nodeEnv === 'production' ? {
'react': 'var React',
'react-dom': 'var ReactDOM',
} : null,
module: {
rules: [{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
}, {
test: /\.css$/,
use: [
'style-loader', {
loader: 'css-loader',
options: {
importLoaders: 1
}
}, {
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('postcss-import')(),
require('cssnext')({
features: {
customProperties: {
preserve: true,
appendVariables: true
}
}
}),
postCSSPrefix(CssClassPrefix, {
ignore: [/react-autosuggest/]
}),
];
}
}
}
]
}]
}, |
@kevinSuttle I opened issue postcss/postcss-load-config#24 |
@ kevinShuttle @farwayer fixed in postcss-load-config v1.0.0-beta |
Guys! Thanks for you tests. Now we fixed most of them. Could you test After 3 “working” reports, I will release new version ;). |
I'm afraid config from readme is not working: {
loader: 'postcss-loader',
options: {
plugins: function () {
return [
require('precss'),
require('autoprefixer')
];
}
}
} Please read webpack/webpack#3018 (comment). |
@farwayer hm, very strange it works for one users, and doesn’t work for rest :-/ |
@ai syntax with loader options or with |
@farwayer new syntax in |
Something wrong with |
OK. @michael-ciniawsky publish |
Loader options configurations will not work with |
1.0 was released. Thanks to everyone for help. |
@ai i've updated to 1.0 and followed instructions in readme for webpack 2.x config (i'm using latest webpack beta.25). Due to issue mentioned by @farwayer i couldn't make it work. Providing options via new webpack.LoaderOptionsPlugin({
options: {
postcss () {
return [ ... ];
}
}
}); Please consider updating the readme, so that people using beta builds of webpack don't waste time running into this. |
@fmal postcss-loader 1.0 doesn't need LoaderOptionsPlugin. Could you show your config, I will try to find issue there. |
@ai add |
@Birowsky define them in |
@ai I prefer keeping all the config inside the webpack config file. So I'll stick with the |
webpack: >v2.0.0-beta.25 webpack.config.js module: {
rules : [{
test: /\.(sass|less|styl|sss|css)$/,
use: [
...// style-loader, css-loader
{
loader: 'postcss-loader',
options: { options: { /* PostCSS Options */ }, plugins: () => [ /* PostCSS Plugins */ ] }
}
...// less-loader, sass-loader, stylus-loader
]
}]
} Basically like in LoaderOptionsPlugin, the plugin was more of an 'polyfill' for webpack 2 < beta.25, webpack 2 development is still a bit in flux :) |
@Oopscurity Your solution worked for me on webpack@2.2.1 |
The latest webpack beta now validates the configuration object, which breaks this usage as the
postcss
key in the configuration is not part of the validated schema. See release notes here: https://github.com/webpack/webpack/releases/tag/v2.1.0-beta.23The entire output is:
I understand this is for a webpack 2 beta, and probably should wait until the features stabilize. Who knows if this configuration validation will land in the final version...
For now I've locked webpack@2.1.0-beta.21
The text was updated successfully, but these errors were encountered: