forked from floating-ui/react-popper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: simplified build, and ship cjs in lib
- Loading branch information
Federico Zivolo
committed
Apr 5, 2018
1 parent
726ecb2
commit d3e2359
Showing
4 changed files
with
63 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,24 +5,22 @@ | |
"license": "MIT", | ||
"author": "Travis Arnold <[email protected]> (http://souporserious.com)", | ||
"homepage": "https://github.com/souporserious/react-popper", | ||
"main": "dist/react-popper.js", | ||
"umd:main": "dist/react-popper.umd.js", | ||
"module": "lib/index.js", | ||
"main": "lib/cjs/index.js", | ||
"module": "lib/es/index.js", | ||
"browser": "dist/react-popper.js", | ||
"typings": "typings/react-popper.d.ts", | ||
"files": [ | ||
"dist", | ||
"lib", | ||
"typings/react-popper.d.ts" | ||
], | ||
"scripts": { | ||
"build": "npm run build:clean && npm run build:es && npm run build:umd && npm run build:cjs && npm run build:flow && npm run build:umd-min && npm run build:cjs-min", | ||
"build": "npm run build:clean && npm run build:es && npm run build:cjs && npm run build:browser && npm run build:flow", | ||
"build:clean": "rimraf dist/ && rimraf lib/", | ||
"build:es": "babel src --ignore '*.test.js,__mocks__' --out-dir lib", | ||
"build:umd": "rollup -c --output.format umd --output.name 'react-popper' --output.file dist/react-popper.umd.js", | ||
"build:cjs": "rollup -c --output.format cjs --output.name 'react-popper' --output.file dist/react-popper.js", | ||
"build:flow": "flow-copy-source --ignore '{__mocks__/*,*.test}.js' src lib", | ||
"build:umd-min": "MINIFY=true rollup -c --output.format umd --output.name 'react-popper' --output.file dist/react-popper.umd.min.js", | ||
"build:cjs-min": "MINIFY=true rollup -c --output.format cjs --output.name 'react-popper' --output.file dist/react-popper.min.js", | ||
"build:es": "BABEL_ENV=es babel src --ignore '*.test.js,__mocks__' --out-dir lib/es", | ||
"build:cjs": "BABEL_ENV=cjs babel src --ignore '*.test.js,__mocks__' --out-dir lib/cjs", | ||
"build:browser": "rollup -c", | ||
"build:flow": "flow-copy-source --ignore '{__mocks__/*,*.test}.js' src lib/es", | ||
"demo": "parcel --out-dir demo/dist demo/index.html", | ||
"test": "npm run test:eslint && npm run test:flow && npm run test:ts && npm run test:jest", | ||
"test:ts": "tsc --project ./typings/tests", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,55 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
import minify from 'rollup-plugin-babel-minify'; | ||
|
||
export default { | ||
const common = { | ||
input: 'src/index.js', | ||
external: [ | ||
'react', | ||
'react-dom', | ||
'popper.js', | ||
'create-react-context', | ||
'warning', | ||
], | ||
}; | ||
|
||
const commonOutput = { | ||
name: 'react-popper', | ||
sourcemap: true, | ||
globals: { | ||
react: 'react', | ||
'prop-types': 'PropTypes', | ||
'popper.js': 'PopperJS', | ||
'create-react-context': 'createContext', | ||
warning: 'warning', | ||
}, | ||
}; | ||
|
||
const babelConfig = { | ||
babelrc: false, | ||
presets: [['env', { modules: false }], 'stage-1', 'react'], | ||
plugins: [ | ||
babel({ | ||
babelrc: false, | ||
presets: [['env', { modules: false }], 'stage-1', 'react'], | ||
plugins: [ | ||
'external-helpers', | ||
['transform-react-remove-prop-types', { mode: 'wrap' }], | ||
], | ||
}), | ||
process.env.MINIFY ? minify() : false, | ||
].filter(Boolean), | ||
external: ['react', 'react-dom', 'prop-types', 'popper.js'], | ||
output: { | ||
sourcemap: true, | ||
globals: { | ||
react: 'react', | ||
'prop-types': 'PropTypes', | ||
'popper.js': 'PopperJS', | ||
'external-helpers', | ||
['transform-react-remove-prop-types', { mode: 'wrap' }], | ||
], | ||
}; | ||
|
||
export default [ | ||
{ | ||
...common, | ||
plugins: [babel(babelConfig)], | ||
output: { | ||
...commonOutput, | ||
format: 'umd', | ||
file: 'dist/react-popper.js', | ||
}, | ||
}, | ||
}; | ||
{ | ||
...common, | ||
plugins: [babel(babelConfig), minify()], | ||
output: { | ||
...commonOutput, | ||
format: 'umd', | ||
file: 'dist/react-popper.min.js', | ||
}, | ||
}, | ||
]; |