Initialize your project
First of all, create a directory for your project then initialize with the npm
command:
1 | mkdir myTools |
Next install rollup:
1 | npm install rollup -D |
Now create a folder for your source files, such as modules
, then create the entry file index.js
in it.
After that create rollup.config.js
:
1 | export default { |
Then add a command to your package.json
file in order to run it more conveniently:
1 | { |
The next time you run the npm run build
command, files will be generated in the lib
directory.
Add TypeScript support
First, we need to install npm packages:
1 | npm install typescript rollup-plugin-typescript2 tslib -D |
Edit rollup.config.js
file to use the TypeScript plugin:
1 | import typescript from "rollup-plugin-typescript"; |
It is time to change the input
value to your new entry file, such as modules/index.ts
.