How to use lost, autoprefixer and postcss-flexibility?

ぐ巨炮叔叔 提交于 2019-12-12 04:11:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!