This repository has been archived by the owner on Aug 4, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d18852
commit 8fec857
Showing
6 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Plugin } from 'rollup'; | ||
|
||
type Replacement = string | ((id: string) => string); | ||
|
||
interface RollupReplaceOptions { | ||
/** | ||
* A minimatch pattern, or array of patterns, of files that should be | ||
* processed by this plugin (if omitted, all files are included by default) | ||
*/ | ||
include?: string | RegExp | ReadonlyArray<string | RegExp> | null; | ||
/** | ||
* Files that should be excluded, if `include` is otherwise too permissive. | ||
*/ | ||
exclude?: string | RegExp | ReadonlyArray<string | RegExp> | null; | ||
/** | ||
* To replace every occurrence of `<@foo@>` instead of every occurrence | ||
* of `foo`, supply delimiters | ||
*/ | ||
delimiters?: [string, string]; | ||
/** | ||
* You can separate values to replace from other options. | ||
*/ | ||
values?: { [str: string]: Replacement }; | ||
|
||
/** | ||
* All other options are treated as `string: replacement` replacers, | ||
* or `string: (id) => replacement` functions. | ||
*/ | ||
[str: string]: Replacement | RollupReplaceOptions['include'] | RollupReplaceOptions['values']; | ||
} | ||
|
||
/** | ||
* Replace strings in files while bundling them. | ||
*/ | ||
export default function replace(options?: RollupReplaceOptions): Plugin; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": [ | ||
"es6" | ||
], | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"allowJs": true | ||
}, | ||
"files": [ | ||
"index.d.ts", | ||
"typings-test.js" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// @ts-check | ||
import { dirname } from 'path'; | ||
import replace from '.'; | ||
|
||
/** @type {import("rollup").RollupOptions} */ | ||
const config = { | ||
input: 'main.js', | ||
output: { | ||
file: 'bundle.js', | ||
format: 'iife' | ||
}, | ||
plugins: [ | ||
replace({ | ||
include: 'config.js', | ||
exclude: 'node_modules/**', | ||
delimiters: ['<@', '@>'], | ||
VERSION: '1.0.0', | ||
ENVIRONMENT: JSON.stringify('development'), | ||
__dirname: id => `'${dirname(id)}'`, | ||
values: { | ||
VERSION: '1.0.0', | ||
ENVIRONMENT: JSON.stringify('development') | ||
} | ||
}) | ||
] | ||
}; | ||
|
||
export default config; |