Skip to content

Commit 53c2a48

Browse files
committed
Tweak readme to more explicitly note legacy Webpack details
1 parent 89dad10 commit 53c2a48

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ module.exports = {
134134

135135
* `passElementProps`: Controls whether props can be passed from the parent to the generated elements. Defaults to `false`.
136136
* `implicitlyImportReact`: Whether to include React and PropTypes in the imports automatically. If set to `false`, you need to either supply React and PropTypes or import them explicitly. Defaults to `true`.
137-
* `markdownItPlugins`: An array of [MarkdownIt plugin instances](https://www.npmjs.org/browse/keyword/markdown-it-plugin) (and optionally their additional arguments) to use within the markdown renderer.
137+
* `markdownItPlugins`: An array of [MarkdownIt plugins](https://www.npmjs.org/browse/keyword/markdown-it-plugin) (and optionally their additional arguments) to use within the markdown renderer. These can be specified either as instances, or as paths as returned by `require.resolve`.
138138

139139
##### MarkdownIt Plugins
140140

@@ -154,7 +154,23 @@ module.exports = {
154154

155155
The configuration above will supply both [`markdown-it-anchor`](https://www.npmjs.com/package/markdown-it-anchor) and [`markdown-it-table-of-contents`](https://www.npmjs.com/package/markdown-it-table-of-contents) to MarkdownIt's `use` method. `markdown-it-table-of-contents` is supplied within an array, and the entire array is passed as the arguments to `use`, allowing specifying plugin configurations.
156156

157-
Note that if you are using Webpack v1, you will need to pass a string with the path to the plugin, rather than the imported/required plugin itself. So in the example above, you should use `require.resolve('markdown-it-anchor')` instead of `require('markdown-it-anchor')`.
157+
###### Legacy Webpack compatibility
158+
159+
For compatibility with Webpack 1.x, where plugin configuration must be JSON compatible, plugins can be passed as path strings rather than the plugin object itself.
160+
161+
The equivalent of the example above in Webpack 1.x would be as follows.
162+
163+
```javascript
164+
module.exports = {
165+
markdownComponentLoader: {
166+
markdownItPlugins: [
167+
require.resolve('markdown-it-anchor'),
168+
[require.resolve('markdown-it-table-of-contents'), { containerClass: 'my-container-class' }]
169+
]
170+
},
171+
{...more}
172+
};
173+
```
158174

159175
### Styling and Interaction
160176

0 commit comments

Comments
 (0)