Skip to content

Commit

Permalink
Change meta.generate to meta.generateFile
Browse files Browse the repository at this point in the history
  • Loading branch information
Giglium committed Nov 29, 2024
1 parent 6fa4fae commit f1ec1b9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 26 deletions.
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,54 @@ A webpack plugin for developing your userscripts with a modern workflow.

Focusing on support for [Tampermonkey](https://www.tampermonkey.net/) and [Violentmonkey](https://violentmonkey.github.io/).

- [Features](#features)
- [Installation](#installation)
- [Quick start](#quick-start)
- [1. Set up the project](#1-set-up-the-project)
- [2. Install the dev script](#2-install-the-dev-script)
- [3. Start developing](#3-start-developing)
- [4. Build for release](#4-build-for-release)
- [Advanced: multiple userscripts](#advanced-multiple-userscripts)
- [More examples](#more-examples)
- [API / Configuration](#api--configuration)
- [`monkey(config)`](#monkeyconfig)
- [`module.hot.monkeyReload(options)`](#modulehotmonkeyreloadoptions)
- [Meta generation](#meta-generation)
- [External dependencies (@require)](#external-dependencies-require)
- [External assets (@resource)](#external-assets-resource)
- [CSS](#css)
- [TypeScript](#typescript)
- [Working with HMR](#working-with-hmr)
- [Comparison with vite-plugin-monkey](#comparison-with-vite-plugin-monkey)
- [Development Notes](DEVELOPMENT.md)
- [webpack-monkey](#webpack-monkey)
- [Features](#features)
- [Installation](#installation)
- [Quick start](#quick-start)
- [1. Set up the project](#1-set-up-the-project)
- [2. Install the dev script](#2-install-the-dev-script)
- [3. Start developing](#3-start-developing)
- [4. Build for release](#4-build-for-release)
- [Advanced: multiple userscripts](#advanced-multiple-userscripts)
- [More examples](#more-examples)
- [API / Configuration](#api--configuration)
- [`monkey(config)`](#monkeyconfig)
- [`debug`](#debug)
- [`meta.resolve`](#metaresolve)
- [`meta.load`](#metaload)
- [`meta.transform`](#metatransform)
- [`meta.generateFile`](#metageneratefile)
- [`require.provider`](#requireprovider)
- [`require.lockVersions`](#requirelockversions)
- [`require.exportsFromUnnamed`](#requireexportsfromunnamed)
- [`require.resolve`](#requireresolve)
- [`devScript.meta`](#devscriptmeta)
- [`devScript.transform`](#devscripttransform)
- [`beautify.prettier`](#beautifyprettier)
- [`terserPluginOptions`](#terserpluginoptions)
- [`module.hot.monkeyReload(options)`](#modulehotmonkeyreloadoptions)
- [`ignore`](#ignore)
- [Meta generation](#meta-generation)
- [External dependencies (@require)](#external-dependencies-require)
- [1. meta.require (simple)](#1-metarequire-simple)
- [2. import with URL (good for tree-shaking)](#2-import-with-url-good-for-tree-shaking)
- [3. Webpack externals with URL (good for tree-shaking and TypeScript)](#3-webpack-externals-with-url-good-for-tree-shaking-and-typescript)
- [4. Webpack externals with global variable (most flexible)](#4-webpack-externals-with-global-variable-most-flexible)
- [External assets (@resource)](#external-assets-resource)
- [CSS](#css)
- [TypeScript](#typescript)
- [meta.ts](#metats)
- [meta.js with JSDoc](#metajs-with-jsdoc)
- [Typing external dependencies](#typing-external-dependencies)
- [Working with HMR](#working-with-hmr)
- [TL;DR](#tldr)
- [Why HMR?](#why-hmr)
- [webpack's standard method](#webpacks-standard-method)
- [webpack-monkey's method](#webpack-monkeys-method)
- [Comparison with vite-plugin-monkey](#comparison-with-vite-plugin-monkey)
- [Vite vs. webpack](#vite-vs-webpack)
- [Plugin differences](#plugin-differences)
- [Is webpack-monkey a plagiarism?](#is-webpack-monkey-a-plagiarism)

## Features

Expand Down Expand Up @@ -316,7 +344,7 @@ Default: `undefined`

Function to transform the meta object before using it for serving or building. Can be used to add or modify meta properties.

#### `meta.generate`
#### `meta.generateFile`

Type: `boolean`\
Default: `true`
Expand Down
10 changes: 5 additions & 5 deletions src/node/MonkeyPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface MonkeyPluginOptions {
resolve?: string | string[] | MetaResolver
load?: MetaLoader
transform?: metaTransformer
generate?: boolean
generateFile?: boolean
}
devScript?: {
meta?:
Expand Down Expand Up @@ -614,10 +614,10 @@ export class MonkeyPlugin {
})

// Generate meta file for userscript (*.meta.js)
if(this.options.meta?.generate ?? true) {
const metaFile = jsFile.replace(/\.user\.js$/, ".meta.js")
compilation.emitAsset(metaFile, new RawSource(metaBlock))
chunk.auxiliaryFiles.add(metaFile)
if (this.options.meta?.generateFile ?? true) {
const metaFile = jsFile.replace(/\.user\.js$/, ".meta.js")
compilation.emitAsset(metaFile, new RawSource(metaBlock))
chunk.auxiliaryFiles.add(metaFile)
}

// Generate userscript file (*.user.js)
Expand Down

0 comments on commit f1ec1b9

Please sign in to comment.