Skip to content
This repository has been archived by the owner on Dec 28, 2018. It is now read-only.

Commit

Permalink
build(rollup): enable babel transform
Browse files Browse the repository at this point in the history
  • Loading branch information
tetsuharuohzeki committed Sep 18, 2016
1 parent 979fc95 commit 9e54d88
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"babel-cli": "^6.14.0",
"babel-core": "^6.14.0",
"babel-loader": "^6.2.5",
"babel-plugin-external-helpers": "^6.8.0",
"babel-plugin-transform-es2015-modules-commonjs": "^6.14.0",
"babel-plugin-transform-inline-environment-variables": "^6.8.0",
"babel-plugin-transform-node-env-inline": "^6.8.0",
Expand All @@ -103,6 +104,7 @@
"postcss-custom-properties": "^5.0.1",
"postcss-import": "^8.1.2",
"rollup": "^0.35.14",
"rollup-plugin-babel": "^2.6.1",
"rollup-plugin-commonjs": "^5.0.3",
"rollup-plugin-node-resolve": "^2.0.0",
"stylelint": "^7.2.0",
Expand Down
44 changes: 44 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const path = require('path');

const nodeResolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const babel = require('rollup-plugin-babel');

const isRelease = process.env.NODE_ENV === 'production';

Expand All @@ -15,6 +16,42 @@ assert.ok(!!KAREN_ENTRY_POINT, 'not found process.env.KAREN_ENTRY_POINT');
const KAREN_CLIENT_DIST_DIR = process.env.KAREN_CLIENT_DIST_DIR;
assert.ok(!!KAREN_CLIENT_DIST_DIR, 'not found process.env.KAREN_CLIENT_DIST_DIR');

const babelPresets = [
];

let babelPlugins = [
// For our target browsers, we need not some transforms.

// es2016 level
'babel-plugin-transform-exponentiation-operator',
// es2017 level
'babel-plugin-syntax-trailing-function-commas',
'babel-plugin-transform-async-to-generator',

// for React
'syntax-jsx',
'transform-react-jsx',

// some utilitis
'transform-inline-environment-variables',
'transform-node-env-inline',

// to remove duplicated helper methods inserted by babel.
'external-helpers',
];

if (isRelease) {
babelPlugins = babelPlugins.concat([
'transform-react-constant-elements',
'transform-react-inline-elements',
]);
}
else {
babelPlugins = babelPlugins.concat([
'transform-react-jsx-source',
]);
}

// https://github.com/rollup/rollup/wiki/JavaScript-API
// https://github.com/rollup/rollup/wiki/Command-Line-Interface
module.exports = {
Expand Down Expand Up @@ -43,5 +80,12 @@ module.exports = {
commonjs({
ignoreGlobal: true,
}),

// https://github.com/rollup/rollup-plugin-babel
babel({
exclude: 'node_modules/**',
presets: babelPresets,
plugins: babelPlugins,
}),
]
};

0 comments on commit 9e54d88

Please sign in to comment.