-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(build): Replace zenflow-build-js-lib with rollup and upgrade ba…
…bel (#70)
- Loading branch information
Showing
4 changed files
with
75 additions
and
24 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,9 +1,6 @@ | ||
{ | ||
"presets": [ | ||
["babel-preset-env"], | ||
["babel-preset-react"] | ||
], | ||
"plugins": [ | ||
["babel-plugin-transform-class-properties"] | ||
["@babel/preset-env"], | ||
["@babel/preset-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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
# TODO | ||
|
||
- put build test (test/test-build.html) in automated harness | ||
- upgrade webpack-serve to >= 2.0.0 and remove from pacakge.greenkeeper.ignore (once the "Module not found: Error: Can't resolve 'webpack-hot-client'" bug is fixed) | ||
|
||
(also search "TODO" in code) |
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,63 @@ | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import babel from 'rollup-plugin-babel' | ||
import { terser } from 'rollup-plugin-terser' | ||
import pkg from './package.json' | ||
|
||
const getBanner = file => `\ | ||
/** @preserve | ||
* package: ${pkg.name} v${pkg.version} | ||
* file: ${file} | ||
* homepage: ${pkg.homepage} | ||
* license: ${pkg.license} | ||
**/\n` | ||
|
||
export default [false, true].map(minify => { | ||
const plugins = [ | ||
resolve(), | ||
commonjs(), | ||
babel({ | ||
exclude: 'node_modules/**', | ||
}), | ||
] | ||
if (minify) { | ||
plugins.push( | ||
terser({ | ||
output: { | ||
comments: (_, { value }) => /@preserve/.test(value), | ||
}, | ||
}), | ||
) | ||
} | ||
return { | ||
input: 'src/index.js', | ||
external: ['react', 'react-dom'], | ||
plugins, | ||
output: [ | ||
{ | ||
format: 'cjs', | ||
}, | ||
{ | ||
format: 'es', | ||
}, | ||
{ | ||
format: 'umd', | ||
name: 'sweetalert2ReactContent', | ||
globals: { | ||
react: 'React', | ||
'react-dom': 'ReactDOM', | ||
}, | ||
}, | ||
].map(({ format, ...rest }) => { | ||
const fileExt = format + (minify ? '.min' : '') + '.js' | ||
const file = `dist/sweetalert2-react-content.${fileExt}` | ||
return { | ||
format, | ||
file, | ||
sourcemap: true, | ||
banner: getBanner(file), | ||
...rest, | ||
} | ||
}), | ||
} | ||
}) |