Package Exports
- tiny-webpack-userscript-plugin
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tiny-webpack-userscript-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Tiny Webpack Userscript Plugin
- Allows one to bundle userscripts, using webpack
- It's one file: TinyWebpackUserscriptPlugin.ts
Usage
This could be your webpack.config.ts:
import { resolve } from 'path';
import { TinyWebpackUserscriptPlugin, IMetaSchema } from 'tiny-webpack-userscript-plugin';
const buildDirectory = resolve(__dirname, './build');
const scriptName = 'TestScript'
export default {
mode: "development",
entry: `./${scriptName}.ts`,
plugins: [
new TinyWebpackUserscriptPlugin({
headers: [
{
name: scriptName,
author: 'jim',
license: 'MIT',
namespace: 'jim',
version: '0.1.0',
updateURL: `http://github.com/nfour/tiny-webpack-userscript-plugin/master/tree/test/build/${scriptName}.user.js`,
downloadURL: `http://github.com/nfour/tiny-webpack-userscript-plugin/master/tree/test/build/${scriptName}.user.js`,
}
],
developmentUrl: 'http://localhost:9002',
})
],
output: {
path: buildDirectory,
filename: `${scriptName}.user.js`
},
resolve: { extensions: ['.ts', '.js'] },
module: {
rules: [{
test: /\.ts$/, use: 'ts-loader', exclude: /node_modules/
}]
},
}
Check out the test project ./test/TinyWebpackUserscriptPlugin.test.ts for a full example!
Development tips
To compile and serve your userscripts at, for at http://localhost:9002/${scriptName}.user.js create a npm script like this:
{
"scripts": {
"dev": "concurrently 'yarn webpack --watch' 'yarn serve -l 9002 build'"
},
"devDependencies": {
"concurrently": "5.1",
"serve": "11.3"
}
}