GithubHelp home page GithubHelp logo

webpack-userscript-test's Introduction

This is a project help you build userscript with webpack

Just use this git repo as a template.

中文说明

dev

  1. Allow Tampermonkey's access to local file URIs tampermonkey/faq
  2. install deps with npm i or npm ci.
  3. npm run dev to start your development.
  4. open webpack-userscript-template/dist/index.dev.user.js in your Chrome and install it with your userscript manager.

this userscript's meta contains // @require file://path/to/dist/index.debug.user.js, which take src/index.ts as entry point.

every times you edit your metadata, you'll have to install it again, because Tampermonkey don't read it from dist every times.

  1. edit src/index.ts, you can even import css or less files. You can use scss if you like.
  2. go wo https://www.example.com/ and open console, you'll see it's working.

livereload is default enabled, use this chrome extension

TypeScript

use typescript as normal, see example

dependencies

There are two ways to using a package on npm.

UserScript way

like original UserScript way, you will need to add them to your user script metadata's require section , and exclude them in config/webpack.config.base.cjs

Webpack way

just install a package and import it in your js file. webpack will pack them with in your final production js file.

build

npm run build

dist/index.prod.user.js is the finally script. you can manually copy it to greaskfork for deploy.

minify

There is a limit in greasyfork, your code must not be obfuscated or minified.

auto deploy

github actions will deploy production userscript to gh-pages branch.

example

deployed

You can auto use greasyfork's auto update function.

webpack-userscript-test's People

Contributors

qhkklm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.