Skip to content

Commit

Permalink
chore(build): Replace zenflow-build-js-lib with rollup and upgrade ba…
Browse files Browse the repository at this point in the history
…bel (#70)
  • Loading branch information
zenflow authored Feb 20, 2019
1 parent 504d149 commit 580398a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 24 deletions.
7 changes: 2 additions & 5 deletions .babelrc
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"]
]
}
1 change: 0 additions & 1 deletion TODO.md
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)
28 changes: 10 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"fix:ts": "npm run lint:ts --fix",
"test-only": "jest --ci",
"test": "npm run check-dts && npm run lint && npm run test-only",
"build": "zenflow-build-js-lib --prod"
"build": "rollup --config"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -50,32 +50,29 @@
"sweetalert2": "^7.18.0"
},
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.3.1",
"@babel/preset-react": "^7.0.0",
"@semantic-release/changelog": "^3.0.1",
"@semantic-release/git": "^7.0.5",
"@types/react": "^16.0.40",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-core": "^7.0.0-bridge.0",
"coveralls": "^3.0.0",
"jest": "^23.6.0",
"npm-run-all": "^4.1.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^4.0.4",
"semantic-release": "^15.0.0",
"sweetalert2": "^7.18.0",
"tslint": "^5.9.1",
"typescript": "^3.1.3",
"zenflow-build-js-lib": "^3.0.0",
"zenflow-lint-js": "^2.0.0"
},
"zenflowConfig": {
"build": {
"globals": {
"react": "React",
"react-dom": "ReactDOM"
}
}
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
Expand All @@ -84,10 +81,5 @@
"coverageDirectory": "coverage",
"testURL": "http://localhost/",
"verbose": true
},
"greenkeeper": {
"ignore": [
"webpack-serve"
]
}
}
63 changes: 63 additions & 0 deletions rollup.config.js
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,
}
}),
}
})

0 comments on commit 580398a

Please sign in to comment.