问题
I want to know the order in which we should use autoprefixer
, lost
, postcssflexibility
in webpack
?
回答1:
Here's a basic example (prefixing through postcss, applying precss plugin etc.).
webpack 1
const autoprefixer = require('autoprefixer');
const precss = require('precss');
module.exports = {
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style', 'css', 'postcss'],
},
],
},
// PostCSS plugins go here
postcss: function () {
return [autoprefixer, precss];
},
};
webpack 2
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
ident: 'postcss', // Needed for now
plugins: function () {
// Set up plugins here
return [
require('autoprefixer'),
require('precss'),
];
},
},
},
],
},
],
},
Another way would be to push the plugins to postcss.config.js as instructed in the postcss-loader documentation. It is more difficult to compose that, though.
Source.
来源:https://stackoverflow.com/questions/36405243/how-to-use-lost-autoprefixer-and-postcss-flexibility