Babel Browser Only
Importing files only for browser. The idea is from http://stackoverflow.com/a/30355080.
TL;DR
This plugin makes you import CSS files in Isomorphic React App!
Example
In
import './css/test.css';import './css/test.scss';;; import React Component from 'react'; ...
Out
processenvBROWSER && ;processenvBROWSER && ;processenvBROWSER && ;processenvBROWSER && ; import React Component from 'react'; ...
Usage
For Webpack
plugins: 'process.env': BROWSER: JSON
For Babel
.babelrc
(Recommended)
Via .babelrc
With Options
{
"plugins": ["babel-browser-only", {
"disregard": [".css", ".scss", ".sass", ".less"] // default
}]
}
Via CLI
$ babel --plugins babel-browser-only script.js
Via Node API
import transform from 'babel-core';;
Installation
npm install --save-dev babel-browser-only