1.0.1 • Published 8 years ago
generator-userscript v1.0.1
generator-userscript

Yeoman generator for building userscripts with TypeScript and Webpack
Installation
First, install Yeoman and generator-userscript using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-userscriptThen generate your new project:
yo userscriptAuthoring your script
- Script metadata can be specified in
src/meta.json.- The contents of this file is validated using the
meta.schema.jsonJSON schema. - By default the script is configured to run on all pages. It is recommended to set up the
includeproperty with rules to be run only on pages the script supports.
- The contents of this file is validated using the
- Script code is written in TypeScript and located in
src/index.ts. You can split your code to modules and include them with animportdirective. - CSS styles to be injected into web pages can be specified in
src/index.cssor any other CSS file imported intosrc/index.ts.- If you do not need custom CSS styles, remove the import to exclude CSS injecting code from the compiled script.
- If you prefer other styling languages like LESS or SASS, you can install a corresponding Webpack loader and configure it in the
webpack.config.tsfile.
Building your script
- All script files are combined into a single JS file with Webpack. The resulting file will be placed into the
dest/directory. - To build a human-readable version of your script, run
npm buildin the Node.js command propmt. - To build a minified version of your script, run
npm build:prodin the Node.js command propmt.
License
MIT © Dark Daskin