Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Wepback #59

Open
sidonaldson opened this issue Feb 16, 2017 · 7 comments
Open

Wepback #59

sidonaldson opened this issue Feb 16, 2017 · 7 comments

Comments

@sidonaldson
Copy link

Has anyone used this with webpack and PostCSS?

You can use postcss.config.js to load variables and plugins and i've tried the following:

module.exports = {
	remove: false,
	plugins: [
		require('autoprefixer')({
			browsers: [
				'>1%',
				'last 2 versions',
				'ie >= 8'
			]
		}),
		require('pixrem')
	]
}

However it doesn't work. Any help is hugely appreciated.

@dotnetCarpenter
Copy link

You should take a look at https://github.com/postcss/postcss-loader

@sidonaldson
Copy link
Author

@dotnetCarpenter please elaborate?

@dotnetCarpenter
Copy link

@sidonaldson Instead of using pixem directly with Webpack, use postcss-loader with pixrem as plugin. https://github.com/postcss/postcss-loader#plugins

@sidonaldson
Copy link
Author

@dotnetCarpenter this is a postCSS plugin. Why and how would I use it directly with Webpack. Clearly you didn't read my question - of course I'm using postcss-loader.

@mooniitt
Copy link

{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// facebook/create-react-app#2677
ident: 'postcss',
plugins: () => [
require('pixrem')({rootValue: 16, replace: false, atrules: false, html: true, browsers: 'ie <= 8', unitPrecision: 3}),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},

my webpack config ,also it's did not work

@malleswar
Copy link

my webpack also not working

ERROR in ./src/index.css (./node_modules/css-loader/dist/cjs.js??ref--5-1!./node_modules/postcss-loader/src??postcss!./src/index.css)
Module build failed (from ./node_modules/postcss-loader/src/index.js):
ReferenceError: autoprefixer is not defined
at Object.plugins (D:\NodeJsWork\CTS\BurgerApp\webpack.config.js:54:17)
at Object.parseOptions (D:\NodeJsWork\CTS\BurgerApp\node_modules\postcss-loader\src\options.js:18:23)
at Promise.resolve.then (D:\NodeJsWork\CTS\BurgerApp\node_modules\postcss-loader\src\index.js:51:27)
at
@ ./src/index.css 2:14-140
@ ./src/index.js

@malleswar
Copy link

options: {
// Necessary for external CSS imports to work
// facebook/create-react-app#2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
},
},

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

No branches or pull requests

4 participants