Skip to content

PostCSS plugin separate the flex child element style into a selector

License

Notifications You must be signed in to change notification settings

noyobo/postcss-flex-item

Repository files navigation

PostCSS Flex Item

CI build status npm

PostCSS plugin separate the flex child element style into a selector.

将 flex 子元素样式分为选择器。

.foo {
  color: red;
  flex: 1;
}
.foo {
  color: red;
}
.flex_foo {
  flex: 1;
}

Required

  • postcss@^7.0.0
  • postcss-loader@^3.0.0

Options

{
  prefix: 'flex_'; // 子元素样式前缀
  validSelector: function (rule.selector) { // 有效的选择器
    return true; // 返回 false 则不处理
  }
}

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-flex-item

Step 2: Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin to plugins list:

module.exports = {
  plugins: [
+   require('postcss-flex-item', { prefix: 'flex_' }),
    require('autoprefixer')
  ]
}

About

PostCSS plugin separate the flex child element style into a selector

Resources

License

Stars

Watchers

Forks

Packages

No packages published