项目作者: axept

项目描述 :
Transform PreJSS constructions to plain JSS objects
高级语言: JavaScript
项目地址: git://github.com/axept/babel-plugin-transform-prejss.git
创建时间: 2017-02-28T10:16:28Z
项目社区:https://github.com/axept/babel-plugin-transform-prejss

开源协议:MIT License

下载


babel-plugin-transform-prejss

Travis branch
npm version
npm downloads
npm license

Babel plugin which turns PreJSS constructions into JSS objects.

Example

In

  1. const button = ({selector}) => preJSS`
  2. button {
  3. color: ${props => props.disabled ? 'grey' : 'red'};
  4. width: 200px;
  5. height: 70px;
  6. &:hover {
  7. text-decoration: underline;
  8. }
  9. }
  10. `

Out

  1. var button = function button(_ref) {
  2. var selector = _ref.selector;
  3. return {
  4. 'button': {
  5. 'color': function color(props) {
  6. return props.disabled ? 'grey' : 'red';
  7. },
  8. 'width': '200px',
  9. 'height': '70px',
  10. '&:hover': {
  11. 'textDecoration': 'underline'
  12. }
  13. }
  14. };
  15. };

See more details here: https://github.com/axept/prejss

Installation

  1. npm install babel-plugin-transform-prejss --save-dev

Usage

Options

  • removeImport: <Boolean|String> - by default is prejss. You can configure it to false if you wouldn’t like to remove imports for “prejss” automatically. But think twice! By disabling this option you may include server code and a lot of unnecessary dependencies into your bundle.

  • silent: <Boolean> - by default is false. This option is configuring if the plugin should or not to log about each removed prejss import.

  • namespace: <String> - by default is preJSS

.babelrc

  1. {
  2. "plugins": ["transform-prejss"]
  3. }

Via CLI

  1. babel --plugins transform-prejss script.js

Via Node API

  1. require("babel-core").transform("code", {
  2. plugins: ["transform-prejss"]
  3. });