-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
3,183 additions
and
757 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,3 @@ | ||
{ | ||
"ignore": ["node_modules/**"], | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
], | ||
"react", | ||
"stage-1" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
"transform-react-remove-prop-types" | ||
] | ||
}, | ||
"development": { | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"browsers": ["last 5 versions", "safari >= 7"] | ||
}, | ||
"modules": false | ||
} | ||
], | ||
"react", | ||
"stage-1" | ||
], | ||
"plugins": [ | ||
"transform-object-rest-spread", | ||
"external-helpers", | ||
"transform-react-remove-prop-types" | ||
] | ||
} | ||
} | ||
"presets": [["@babel/env", { "loose": true }], "@babel/react"], | ||
} |
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,7 @@ | ||
'use strict'; | ||
|
||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./dist/react-epic-spinners.cjs.min.js'); | ||
} else { | ||
module.exports = require('./dist/react-epic-spinners.cjs.js'); | ||
} |
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 |
---|---|---|
@@ -1,43 +1,122 @@ | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import babel from 'rollup-plugin-babel'; | ||
import replace from 'rollup-plugin-replace'; | ||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'; | ||
import { uglify } from 'rollup-plugin-uglify'; | ||
|
||
import pkg from './package.json'; | ||
|
||
export default [ | ||
// browser-friendly UMD build | ||
const input = 'src/index.js'; | ||
const globalName = 'ReactEpicSpinners'; | ||
|
||
function external(id) { | ||
return !id.startsWith('.') && !id.startsWith('/'); | ||
} | ||
|
||
const cjs = [ | ||
{ | ||
input, | ||
output: { file: `dist/${pkg.name}.cjs.js`, format: 'cjs' }, | ||
external, | ||
plugins: [ | ||
babel({ exclude: /node_modules/ }), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }) | ||
] | ||
}, | ||
{ | ||
input: 'src/index.js', | ||
input, | ||
output: { file: `dist/${pkg.name}.cjs.min.js`, format: 'cjs' }, | ||
external, | ||
plugins: [ | ||
babel({ exclude: /node_modules/ }), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), | ||
uglify() | ||
] | ||
} | ||
]; | ||
|
||
const esm = [ | ||
{ | ||
input, | ||
output: { file: `dist/${pkg.name}.esm.js`, format: 'esm' }, | ||
external, | ||
plugins: [ | ||
babel({ | ||
exclude: /node_modules/, | ||
runtimeHelpers: true, | ||
plugins: [['@babel/transform-runtime', { useESModules: true }]] | ||
}), | ||
sizeSnapshot() | ||
] | ||
} | ||
]; | ||
|
||
const globals = { | ||
react: 'React', | ||
'prop-types': 'PropTypes', | ||
'styled-components': 'StyledComponents' | ||
}; | ||
|
||
const umd = [ | ||
{ | ||
input, | ||
output: { | ||
file: pkg.browser, | ||
file: `dist/${pkg.name}.umd.js`, | ||
format: 'umd', | ||
name: 'ReactEpicSpinners', | ||
name: globalName, | ||
globals | ||
}, | ||
external, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
babel({ | ||
exclude: ['node_modules/**'], | ||
exclude: /node_modules/, | ||
}), | ||
], | ||
external: ['react', 'prop-types', 'styled-components'], | ||
resolve(), | ||
commonjs({ | ||
include: /node_modules/ | ||
}), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), | ||
sizeSnapshot() | ||
] | ||
}, | ||
|
||
// CommonJS (for Node) and ES module (for bundlers) build. | ||
// (We could have three entries in the configuration array | ||
// instead of two, but it's quicker to generate multiple | ||
// builds from a single configuration where possible, using | ||
// the `targets` option which can specify `dest` and `format`) | ||
{ | ||
input: 'src/index.js', | ||
output: [ | ||
{ file: pkg.main, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
], | ||
input, | ||
output: { | ||
file: `dist/${pkg.name}.umd.min.js`, | ||
format: 'umd', | ||
name: globalName, | ||
globals | ||
}, | ||
external, | ||
plugins: [ | ||
babel({ | ||
exclude: ['node_modules/**'], | ||
exclude: /node_modules/, | ||
}), | ||
], | ||
external: ['react', 'prop-types', 'styled-components'], | ||
}, | ||
resolve(), | ||
commonjs({ | ||
include: /node_modules/ | ||
}), | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), | ||
sizeSnapshot(), | ||
uglify() | ||
] | ||
} | ||
]; | ||
|
||
let config; | ||
switch (process.env.BUILD_ENV) { | ||
case 'cjs': | ||
config = cjs; | ||
break; | ||
case 'esm': | ||
config = esm; | ||
break; | ||
case 'umd': | ||
config = umd; | ||
break; | ||
default: | ||
config = cjs.concat(esm).concat(umd); | ||
} | ||
|
||
export default config; |
Oops, something went wrong.