diff --git a/package.json b/package.json index e169982..ee0d8c3 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "./dist/png-js.es.js": "./dist/png-js.browser.es.js", "./dist/png-js.cjs.js": "./dist/png-js.browser.cjs.js" }, + "react-native": "./dist/png-js.native.cjs.js", "author": { "name": "Devon Govett", "email": "devongovett@gmail.com", @@ -40,5 +41,8 @@ "path": "./dist/png-js.browser.cjs.min.js", "maxSize": "2kB" } - ] + ], + "dependencies": { + "react-zlib-js": "^1.0.4" + } } diff --git a/rollup.config.js b/rollup.config.js index 28fb8ec..087e409 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -74,9 +74,39 @@ const browserProdConfig = Object.assign({}, browserConfig, { ), }) +const nativePaths = { + zlib: 'react-zlib-js' +} + +const nativeConfig = Object.assign({}, configBase, { + output: [ + getESM({ file: 'dist/png-js.native.es.js', paths: nativePaths }), + getCJS({ file: 'dist/png-js.native.cjs.js', paths: nativePaths }), + ], + plugins: configBase.plugins.concat( + replace({ + BROWSER: JSON.stringify(true), + "png-js": "png-js/png.js" + }), + ignore(['fs']) + ) +}) + +const nativeProdConfig = Object.assign({}, nativeConfig, { + output: [ + getESM({ file: 'dist/png-js.native.es.min.js', paths: nativePaths }), + getCJS({ file: 'dist/png-js.native.cjs.min.js', paths: nativePaths }), + ], + plugins: nativeConfig.plugins.concat( + uglify() + ), +}) + export default [ serverConfig, serverProdConfig, browserConfig, - browserProdConfig + browserProdConfig, + nativeConfig, + nativeProdConfig ] diff --git a/yarn.lock b/yarn.lock index 25e5307..6154f4a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1505,6 +1505,10 @@ rc@^1.1.6: minimist "^1.2.0" strip-json-comments "~2.0.1" +react-zlib-js@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/react-zlib-js/-/react-zlib-js-1.0.4.tgz#dd2b9fbf56d5ab224fa7a99affbbedeba9aa3dc7" + read-pkg-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07"