framework/js-packages/webpack-config/README.md

40 lines
1.1 KiB
Markdown
Raw Normal View History

2018-06-16 13:04:12 +08:00
**Webpack config factory for Flarum JavaScript compilation.**
2018-02-24 13:59:19 +08:00
2018-06-16 13:04:12 +08:00
This package generates a [Webpack](https://webpack.js.org) config object that will compile JavaScript for use in Flarum.
## Usage
**webpack.config.js**
2018-02-24 13:59:19 +08:00
```js
var config = require('flarum-webpack-config');
2018-06-16 13:04:38 +08:00
module.exports = config(options);
2018-02-24 13:59:19 +08:00
```
2018-06-16 13:04:12 +08:00
To merge in custom Webpack config options, use [webpack-merge](https://www.npmjs.com/package/webpack-merge).
2018-06-16 13:04:38 +08:00
## Options
### `useExtensions`
`Array<string>`, defaults to `[]`.
An array of extensions whose modules should be made available. This is a shortcut to add [`externals`](https://webpack.js.org/configuration/externals/) configuration for extension modules. Imported extension modules will not be bundled, but will instead refer to the extension's exports included in the Flarum runtime (ie. `flarum.extensions["vendor/package"]`).
For example, to access the Tags extension module within your extension:
**forum.js**
```js
import { Tag } from '@flarum/flarum-ext-tags/forum';
```
**webpack.config.js**
```js
module.exports = config({
useExtensions: ['flarum/flarum-ext-tags']
});
```