Skip to content

Instantly share code, notes, and snippets.

import path from 'path';
import fs from 'fs';
import { generate } from 'astring'
interface Options {
test: RegExp;
include: string[];
dir: string;
}
@ZKHelloworld
ZKHelloworld / dev-sourcemap-webpack-plugin.js
Created June 10, 2021 03:40
dev-sourcemap-webpack-plugin
const path = require('path');
const { RawSource } = require('webpack').sources;
const PLUGIN_NAME = 'DevSourcemapWebpackPlugin';
class DevSourcemapWebpackPlugin {
constructor(options) {
this.test = options.test || new RegExp(`${PLUGIN_NAME}__no_source_map_reg__`);
}
apply(compiler) {
@ZKHelloworld
ZKHelloworld / async-jsonp-webpack-plugin.js
Last active June 10, 2021 03:38
async-jsonp-webpack-plugin
const { RawSource, CachedSource } = require('webpack').sources;
const Compilation = require('webpack').Compilation;
const PLUGIN_NAME = 'AsyncJsonpWebpackPlugin';
/**
* modify webpack output to async jsonp
*
* before:
* (() => {
* // sync code run