2021-05-21 05:09:15 +08:00
|
|
|
# Webpack config for Flarum JS/TS 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
|
|
|
|
2021-05-13 07:05:27 +08:00
|
|
|
### Webpack Bundle Analyzer
|
|
|
|
|
|
|
|
You can view a visual representation of your JS Bundle by building with Webpack Bundle Analyzer.
|
|
|
|
|
|
|
|
Add another build script to your `package.json` like the one below:
|
|
|
|
|
|
|
|
```json
|
|
|
|
{
|
|
|
|
"analyze": "npx cross-env ANALYZER=true npm run build"
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-05-12 08:28:31 +08:00
|
|
|
## Typescript
|
|
|
|
|
|
|
|
You'll need to configure a `tsconfig.json` file to ensure your IDE sets up Typescript support correctly.
|
|
|
|
|
|
|
|
For details about this, see the [`flarum/flarum-tsconfig` repository](https://github.com/flarum/flarum-tsconfig)
|