-
-
Notifications
You must be signed in to change notification settings - Fork 203
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(custom-esbuild): add support for plugin configuration
- Loading branch information
1 parent
861f785
commit 8516e5d
Showing
15 changed files
with
185 additions
and
15 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
11 changes: 11 additions & 0 deletions
11
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-by-option-plugin.cjs
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,11 @@ | ||
function defineTitleByOptionPlugin(pluginOptions) { | ||
return { | ||
name: 'define-title', | ||
setup(build) { | ||
const options = build.initialOptions; | ||
options.define.titleByOption = JSON.stringify(pluginOptions.title); | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports = defineTitleByOptionPlugin; |
11 changes: 11 additions & 0 deletions
11
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-by-option-plugin.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,11 @@ | ||
function defineTitleByOptionPlugin(pluginOptions) { | ||
return { | ||
name: 'define-title', | ||
setup(build) { | ||
const options = build.initialOptions; | ||
options.define.titleByOption = JSON.stringify(pluginOptions.title); | ||
}, | ||
}; | ||
}; | ||
|
||
export default defineTitleByOptionPlugin; |
13 changes: 13 additions & 0 deletions
13
examples/custom-esbuild/sanity-esbuild-app-esm/esbuild/define-text-by-option-plugin.ts
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,13 @@ | ||
import type { Plugin, PluginBuild } from 'esbuild'; | ||
|
||
function defineTitleByOptionPlugin(pluginOptions: {title: string}): Plugin { | ||
return { | ||
name: 'define-title', | ||
setup(build: PluginBuild) { | ||
const options = build.initialOptions; | ||
options.define!['titleByOption'] = JSON.stringify(pluginOptions.title); | ||
}, | ||
}; | ||
}; | ||
|
||
export default defineTitleByOptionPlugin; |
1 change: 1 addition & 0 deletions
1
examples/custom-esbuild/sanity-esbuild-app-esm/src/app/app.component.html
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<h1>{{ title }}</h1> | ||
<h2>{{ subtitle }}</h2> | ||
<h3>{{ titleByOption }}</h3> |
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
12 changes: 12 additions & 0 deletions
12
examples/custom-esbuild/sanity-esbuild-app/esbuild/define-text-by-option-plugin.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,12 @@ | ||
function defineTitleByOptionPlugin(pluginOptions) { | ||
return { | ||
name: 'define-title', | ||
setup(build) { | ||
console.log('pluginOptions', pluginOptions); | ||
const options = build.initialOptions; | ||
options.define.titleByOption = JSON.stringify(pluginOptions.title); | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports = defineTitleByOptionPlugin; |
12 changes: 12 additions & 0 deletions
12
examples/custom-esbuild/sanity-esbuild-app/esbuild/define-text-by-option-plugin.mjs
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,12 @@ | ||
function defineTitleByOptionPlugin(pluginOptions) { | ||
return { | ||
name: 'define-title', | ||
setup(build) { | ||
console.log('pluginOptions', pluginOptions); | ||
const options = build.initialOptions; | ||
options.define.titleByOption = JSON.stringify(pluginOptions.title); | ||
}, | ||
}; | ||
}; | ||
|
||
export default defineTitleByOptionPlugin; |
1 change: 1 addition & 0 deletions
1
examples/custom-esbuild/sanity-esbuild-app/src/app/app.component.html
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<h1>{{ title }}</h1> | ||
<h2>{{ subtitle }}</h2> | ||
<h3>{{ titleByOption }}</h3> |
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
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
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