Created
October 3, 2018 12:41
-
-
Save romanlex/c6b5d10ec6c0429e333d951c6f86c47a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import peerDepsExternal from 'rollup-plugin-peer-deps-external' | |
import alias from 'rollup-plugin-alias' | |
import babel from 'rollup-plugin-babel' | |
import commonjs from 'rollup-plugin-commonjs' | |
import json from 'rollup-plugin-json' | |
import filesize from 'rollup-plugin-filesize' | |
import resolve from 'rollup-plugin-node-resolve' | |
import replace from 'rollup-plugin-replace' | |
import { eslint } from 'rollup-plugin-eslint' | |
import cleaner from 'rollup-plugin-cleaner' | |
import { uglify } from 'rollup-plugin-uglify' | |
import browserifyPlugin from 'rollup-plugin-browserify-transform' | |
import brfs from 'brfs' | |
const aliases = require('./aliases') | |
const stripFSInterop = function() { | |
return { | |
renderChunk(code) { | |
code = code.replace("var fs = _interopDefault(require('fs'));", "var fs = require('fs');") | |
return { | |
code, | |
map: null, | |
} | |
}, | |
} | |
} | |
const defaultPlugins = [ | |
cleaner({ | |
targets: ['./build/'], | |
}), | |
eslint({ | |
include: 'src/**', | |
}), | |
peerDepsExternal(), | |
json(), | |
alias(aliases), | |
replace({ | |
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'), | |
}), | |
resolve({ | |
module: true, | |
browser: true, | |
jsnext: true, | |
}), | |
commonjs({ | |
include: 'node_modules/**', | |
}), | |
// browserifyPlugin(brfs, { | |
// include: [ | |
// 'node_modules/pdfkit/**', | |
// 'node_modules/brotli/**', | |
// 'node_modules/fontkit/**', | |
// // 'node_modules/linebreak/**', | |
// // 'node_modules/png-js/**', | |
// 'node_modules/unicode-properties/**', | |
// ], | |
// }), | |
babel({ | |
babelrc: false, | |
presets: [ | |
[ | |
'@babel/preset-env', | |
{ | |
modules: false, | |
targets: { | |
browsers: ['Firefox 57', 'Edge 15', 'Chrome 60', 'iOS 10', 'Safari 10'], | |
}, | |
}, | |
], | |
], | |
plugins: [ | |
['@babel/plugin-proposal-decorators', { legacy: true }], | |
'@babel/plugin-proposal-class-properties', | |
'@babel/plugin-proposal-object-rest-spread', | |
'@babel/plugin-transform-runtime', | |
], | |
runtimeHelpers: true, | |
externalHelpers: true, | |
}), | |
stripFSInterop(), | |
filesize(), | |
] | |
if (process.env.NODE_ENV === 'production') { | |
defaultPlugins.push( | |
uglify({ | |
compress: { | |
pure_getters: true, | |
unsafe: true, | |
unsafe_comps: true, | |
warnings: false, | |
}, | |
}) | |
) | |
} | |
export default { | |
input: 'src/worker/worker.js', | |
output: { | |
file: 'build/pdf-worker.js', | |
format: 'umd', | |
name: 'PDFGeneratorWorker', | |
sourcemap: true, | |
}, | |
plugins: defaultPlugins, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment