Skip to content

Commit

Permalink
build: update rollup config
Browse files Browse the repository at this point in the history
  • Loading branch information
akameco committed Feb 6, 2019
1 parent d40a5c9 commit b5dfaf7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 54 deletions.
25 changes: 8 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,22 @@
"email": "[email protected]",
"url": "https://akameco.github.io"
},
"main": "lib/index.js",
"jsnext:main": "dist/styled-spinkit.es.js",
"module": "dist/styled-spinkit.es.js",
"main": "dist/index.js",
"jsnext:main": "dist/styled-spinkit.esm.js",
"module": "dist/styled-spinkit.esm.js",
"typings": "dist/index.d.ts",
"keywords": [
"react",
"styled-components",
"components",
"flow",
"flowtype",
"Spinner",
"Loading",
"components"
],
"scripts": {
"add-contributors": "all-contributors add",
"prebuild:lib": "rimraf lib/*",
"build": "npm run build:lib && npm run build:dist && npm run build:flow",
"build:lib": "babel src/ -d lib/ --ignore '**/*.test.js'",
"prebuild:dist": "rimraf dist/*",
"build:dist": "rollup -c",
"build:flow": "flow-copy-source -v -i '{**/tests/*.js,**/*.test.js}' src lib",
"build": "tsc && rollup -c",
"prebuild": "rimraf dist/*",
"fmt": "prettier --write '**/*.{js,json,md}'",
"storybook": "start-storybook -p 9009",
"build-storybook": "build-storybook",
Expand All @@ -47,10 +42,7 @@
]
},
"files": [
"flow-typed",
"lib",
"dist",
"src"
"dist"
],
"dependencies": {
"prop-types": "^15.6.2",
Expand Down Expand Up @@ -94,9 +86,8 @@
"rimraf": "2.6.3",
"rollup": "1.1.2",
"rollup-plugin-babel": "4.3.2",
"rollup-plugin-commonjs": "9.2.0",
"rollup-plugin-flow": "1.1.1",
"rollup-plugin-node-resolve": "4.0.0",
"rollup-plugin-terser": "^4.0.4",
"storyshots": "3.2.2",
"styled-components": "4.1.3",
"stylelint": "9.10.1",
Expand Down
76 changes: 39 additions & 37 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import babel from 'rollup-plugin-babel'
import flow from 'rollup-plugin-flow'
import resolve from 'rollup-plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'

const plugins = [
flow(),
nodeResolve(),
babel({
babelrc: false,
presets: [
['@babel/preset-env', { loose: true, modules: false }],
'@babel/preset-react',
],
plugins: [
'flow-react-proptypes',
'@babel/plugin-transform-flow-strip-types',
['@babel/plugin-proposal-class-properties', { loose: true }],
[
'styled-components',
{
displayName: false,
},
],
].filter(Boolean),
ignore: ['*.test.js'],
}),
commonjs({ ignoreGlobal: true }),
]
const input = './compiled/index.js'

const external = id => !id.startsWith('.') && !id.startsWith('/')

export default {
plugins,
external: ['react', 'styled-components'],
input: 'src/index.js',
const buildCjs = () => ({
input,
external,
output: {
file: 'dist/styled-spinkit.es.js',
format: 'es',
exports: 'named',
globals: { react: 'React' },
file: pkg.main,
format: 'cjs',
sourcemap: true,
},
}
plugins: [
resolve(),
terser({
sourcemap: true,
output: { comments: false },
warnings: true,
ecma: 5,
// Compress and/or mangle variables in top level scope.
// @see https://github.com/terser-js/terser
toplevel: true,
}),
],
})

export default [
buildCjs(),
{
input,
external,
output: {
file: pkg.module,
format: 'esm',
sourcemap: true,
},
plugins: [resolve()],
},
]

0 comments on commit b5dfaf7

Please sign in to comment.