I need to publish minified version of an NPM package written in Typescript. To compile the app I use tsc -p.
command and it builds the package in lib
folder. I feel that lib
is somewhat similar to src
folder in terms of size as it has unnecessary folder, sub-folders and files.
Is it possible to minify and uglify this lib
folder into just a single index.min.js
file?
PS this package is a CLI tool. Is there any need to ship type definitions in d.ts
files? All they contain is just types for functions and variables used in the code.
Thanks!
To merge everything into one file you need to set the outFile
property in your typescript property
{
"compilerOptions": {
"outFile": "./lib/index.js"
// more configs here
},
"exclude": [
"node_modules"
]
}
For minification you have to use an external tool since Typescript does not have any option for that and maybe it will never have since it is an open request since 2014
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.