-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: fix rollup build * perf: enable loose mode (reduce build size)
- Loading branch information
1 parent
121b76b
commit fea2cc0
Showing
6 changed files
with
169 additions
and
103 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ dist/ | |
docs/ | ||
node_modules/ | ||
.DS_Store | ||
.size-snapshot.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.docz/ | ||
src/ | ||
node_modules/ | ||
/* | ||
!/dist/*.js | ||
*.test.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
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,54 +1,44 @@ | ||
import { terser } from 'rollup-plugin-terser' | ||
import babel from 'rollup-plugin-babel' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import nodeResolve from 'rollup-plugin-node-resolve' | ||
import postcss from 'rollup-plugin-postcss' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import { sizeSnapshot } from 'rollup-plugin-size-snapshot' | ||
|
||
const base = { | ||
input: 'src/index.js', | ||
external: [ | ||
'react', | ||
'react-dom', | ||
'react-router-dom', | ||
'prop-types', | ||
'styled-components', | ||
'lodash.merge', | ||
'lodash.get', | ||
'lodash.concat' | ||
import pkg from './package.json' | ||
|
||
const input = 'src/index.js' | ||
const external = id => !id.startsWith('.') && !id.startsWith('/') | ||
const getBabelOptions = ({ useESModules }) => ({ | ||
exclude: '**/node_modules/**', | ||
runtimeHelpers: true, | ||
configFile: './babel.config.js', | ||
plugins: [ | ||
'babel-plugin-annotate-pure-calls', | ||
['@babel/plugin-transform-runtime', { useESModules }] | ||
] | ||
} | ||
}) | ||
|
||
const globals = { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
'react-router-dom': 'ReactRouterDOM', | ||
'styled-components': 'styled', | ||
'lodash.merge': 'merge', | ||
'lodash.get': 'get', | ||
'lodash.concat': 'concat' | ||
const cjsConfig = { | ||
input, | ||
output: { file: pkg.main, format: 'cjs' }, | ||
external, | ||
plugins: [ | ||
babel(getBabelOptions({ useESModules: false })), | ||
nodeResolve(), | ||
postcss(), | ||
sizeSnapshot() | ||
] | ||
} | ||
|
||
const plugins = [babel({ exclude: 'node_modules/**' }), resolve(), commonjs(), postcss()] | ||
const esmConfig = { | ||
input, | ||
output: { file: pkg.module, format: 'esm' }, | ||
external, | ||
plugins: [ | ||
babel(getBabelOptions({ useESModules: true })), | ||
nodeResolve(), | ||
postcss(), | ||
sizeSnapshot() | ||
] | ||
} | ||
|
||
export default [ | ||
{ | ||
...base, | ||
plugins: [terser(), ...plugins], | ||
output: { | ||
globals, | ||
file: 'dist/cjs/welcome-ui.js', | ||
format: 'cjs', | ||
name: 'JungleUI', | ||
esModule: false | ||
} | ||
}, | ||
{ | ||
...base, | ||
plugins, | ||
output: { | ||
globals, | ||
file: 'dist/esm/index.js', | ||
format: 'esm' | ||
} | ||
} | ||
] | ||
export default [cjsConfig, esmConfig] |
Oops, something went wrong.
fea2cc0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://welcome-ui-8zrm8au3v.now.sh to the following aliases.