forked from vuejs/vue-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for metalsmith builder hooks (vuejs#428)
* Add support for metalsmith builder hooks Close vuejs#427 * Fix style * Fix documentation sentence * Add e2e test for metalsmith custom plugin * Enhance e2e tests for metalsmith custom plugin
- Loading branch information
Showing
7 changed files
with
132 additions
and
6 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
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,21 @@ | ||
module.exports = { | ||
"metalsmith": { | ||
before: function (metalsmith, opts, helpers) { | ||
metalsmith.metadata().before = "Before"; | ||
}, | ||
after: function (metalsmith, opts, helpers) { | ||
metalsmith.metadata().after = "After"; | ||
function customMetalsmithPlugin (files, metalsmith, done) { | ||
// Implement something really custom here. | ||
|
||
var readme = files['readme.md'] | ||
delete files['readme.md'] | ||
files['custom-before-after/readme.md'] = readme | ||
|
||
done(null, files) | ||
} | ||
|
||
metalsmith.use(customMetalsmithPlugin) | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/e2e/mock-metalsmith-custom-before-after/template/readme.md
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 @@ | ||
Metalsmith {{after}} and {{before}} hooks |
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 @@ | ||
module.exports = { | ||
"metalsmith": function (metalsmith, opts, helpers) { | ||
metalsmith.metadata().custom = "Custom"; | ||
function customMetalsmithPlugin (files, metalsmith, done) { | ||
// Implement something really custom here. | ||
|
||
var readme = files['readme.md'] | ||
delete files['readme.md'] | ||
files['custom/readme.md'] = readme | ||
|
||
done(null, files) | ||
} | ||
|
||
metalsmith.use(customMetalsmithPlugin) | ||
} | ||
} |
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 @@ | ||
Metalsmith {{custom}} |
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