How to use the createFilter function from rollup-pluginutils
Find comprehensive JavaScript rollup-pluginutils.createFilter code examples handpicked from public code repositorys.
rollup-pluginutils.createFilter is a function that creates a filter to include or exclude files based on certain criteria.
GitHub: hellof2e/quark-design
899 900 901 902 903 904 905 906 907 908 909
return result } /* eslint import/no-anonymous-default-export: [2, {"allowArrowFunction": true}] */ var index = (options = {}) => { const filter = rollupPluginutils.createFilter( options.include, options.exclude ) const postcssPlugins = Array.isArray(options.plugins)
+ 29 other calls in file
129 130 131 132 133 134 135 136 137 138
* @returns Filter function that returns true if a given file matches the filter. */ const makeFilter = (opts, exts) => { opts = opts || {}; // Create the rollup default filter const filter = rollupPluginutils.createFilter(opts.include, opts.exclude); exts = opts.extensions || exts; if (!exts || exts === '*') { return filter; }
How does rollup-pluginutils.createFilter work?
rollup-pluginutils.createFilter is a utility function that creates a filter function to include or exclude files based on certain criteria, such as file extension or file path. It takes in a configuration object and returns a filter function that can be used in a Rollup plugin. The filter function can be used to selectively include or exclude files from being processed by the plugin based on the criteria specified in the configuration object.
GitHub: myntra/applique-ui
6 7 8 9 10 11 12 13 14 15 16
/** * @returns {import('rollup').Plugin} */ module.exports = function ScssPlugin(options = {}) { const isMatched = createFilter(options.include, options.exclude) const postcssOptions = options.postcss || {} const moduleOptions = options.modules || {} const modulesExported = {} const processor = postcss([
+ 33 other calls in file
17 18 19 20 21 22 23 24 25 26 27 28
return values; } } function replace(options = {}) { const filter = rollupPluginutils.createFilter(options.include, options.exclude); const replaceValues = getReplacements(options); return { name: 'replace',
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
import { createFilter } from "rollup-pluginutils"; export default function myPlugin(options) { const filter = createFilter(options.include, options.exclude); return { name: "my-plugin", transform(code, id) { if (!filter(id)) { return null; } // plugin logic here }, }; }
In this example, createFilter is used to create a filter function based on the include and exclude options passed to the plugin. This filter function is then used to determine whether to include or exclude a particular file from the plugin's transform logic.
10 11 12 13 14 15 16 17 18 19 20 21 22
const config = require('./config.js'); var cacheFilesParse = {}; function gettext( options = {} ) { const filter = createFilter( options.include, options.exclude ); const languageFiles = options.languageFiles || config.defaultLanguage; const language = options.language || languageFiles;
5 6 7 8 9 10 11 12 13 14 15 16
const nodeResolve = require('rollup-plugin-node-resolve'); const babel = require('rollup-plugin-babel'); const commonjs = require('rollup-plugin-commonjs'); const readFile = promisify(fs.readFile); const scssFilter = createFilter('**/*.scss'); module.exports = { plugins: [ nodeResolve({
36 37 38 39 40 41 42 43 44
compileConfig = compileConfig || requireCompiler(); } catch (err) { throw new Error('cannot find local <bpmnlint>. Install it or provide a configuration compiler throught the <compileConfig> option.'); } const filter = createFilter(include, exclude); return { name: 'bpmnlint',
+ 27 other calls in file
GitHub: AndZinov/HomeWorkJS
108 109 110 111 112 113 114 115 116 117 118 119 120
function img(opt) { if ( opt === void 0 ) opt = {}; var extensions = opt.extensions || /\.(png|jpg|jpeg|gif|svg)$/; var filter = rollupPluginutils.createFilter(opt.include, opt.exclude); return { name: 'image', load: function load(id) {
+ 33 other calls in file
5 6 7 8 9 10 11 12 13 14 15 16 17
var istanbul = _interopDefault(require('istanbul')); var index = function () { var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; var filter = rollupPluginutils.createFilter(options.include, options.exclude); return { transform: function transform(code, id) { if (!filter(id)) return;
+ 27 other calls in file
GitHub: Mr-wang007s/wei-ui
35 36 37 38 39 40 41 42 43 44
} const isServer = options.target === 'node' const isProduction = process.env.NODE_ENV === 'production' || process.env.BUILD === 'production' const rootContext = process.cwd() const filter = rollup_pluginutils_1.createFilter( options.include, options.exclude ) const filterCustomBlock = createCustomBlockFilter(options.customBlocks)
242 243 244 245 246 247 248 249 250 251
options = options || {}; var basedir = options.baseDir || '/'; var dirs = new Map(); var opts = clone(options); var exclude = (opts.exclude || []).concat(GLOBAL_PATH); var filter = rollupPluginutils.createFilter(options.include, exclude); var sourceMap = options.sourceMap !== false; var _getMods = getMods(options), mods1 = _getMods.mods1,
+ 27 other calls in file
rollup-pluginutils.createFilter is the most popular function in rollup-pluginutils (190 examples)