framework/js-packages/webpack-config
Sami Mazouz 27fb011bf5
chore: with yarn workspaces we only need a single yarn.lock (#3464)
* chore: yarn workspaces means we only need a single `yarn.lock`
* fix: add a `cache_dependency_path` workflow input
* fix: re-introduce `env.cache_dependency_path`
2022-06-19 19:01:21 +01:00
..
.yarn/releases feat: add support for Plug'n'Play package managers (#14) 2021-11-08 23:53:18 +00:00
.gitignore feat: add support for Plug'n'Play package managers (#14) 2021-11-08 23:53:18 +00:00
.prettierrc.json Fix Flarum on iOS 10 and below (#9) 2021-05-04 00:39:10 +01:00
.yarnrc.yml feat: add support for Plug'n'Play package managers (#14) 2021-11-08 23:53:18 +00:00
index.js feat: add support for Plug'n'Play package managers (#14) 2021-11-08 23:53:18 +00:00
LICENSE Update copyright year 2021-05-15 00:54:10 +01:00
package.json feat: add support for Plug'n'Play package managers (#14) 2021-11-08 23:53:18 +00:00
README.md Change first line to be a heading 2021-05-20 22:09:15 +01:00

Webpack config for Flarum JS/TS compilation

This package generates a Webpack config object that will compile JavaScript for use in Flarum.

Usage

webpack.config.js

var config = require('flarum-webpack-config');

module.exports = config(options);

To merge in custom Webpack config options, use webpack-merge.

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:

{
  "analyze": "npx cross-env ANALYZER=true npm run build"
}

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

Options

useExtensions

Array<string>, defaults to [].

An array of extensions whose modules should be made available. This is a shortcut to add 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

import { Tag } from '@flarum/tags/forum';

webpack.config.js

module.exports = config({
  useExtensions: ['flarum/tags'],
});