Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/configurable es modules #97

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/font-config-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,21 @@ module.exports = {
],
};
```

### Enable ES module syntax

By default the `font-config-webpack-plugin` uses the CommonJS modules syntax (`require` statements).
You can enable the ES module syntax (`import` statements) syntax using: `esModule: true` in the options.

For more information see [file-loader documentation](https://v4.webpack.js.org/loaders/file-loader/#esmodule)

```js
const FontConfigWebpackPlugin = require('font-config-webpack-plugin');
module.exports = {
plugins: [
new FontConfigWebpackPlugin({
esModule: true,
}),
],
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports = module.exports = (options) => ({
loader: require.resolve('file-loader'),
options: {
name: options.name,
esModule: options.esModule,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
* Plugin Options
* @typedef {{
mode?: 'production' | 'development'
name: string,
esModule?: boolean
name: string
}} FontConfigWebpackPluginOptions */

'use strict';
/**
* @type {FontConfigWebpackPluginOptions}
*/
const defaultOptions = { name: 'static/media/[name].[hash:8].[ext]' };
const defaultOptions = { name: 'static/media/[name].[hash:8].[ext]', esModule: false };

class FontConfigWebpackPlugin {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('FontConfigWebpackPlugin standalone', () => {
});

it('should return an instance with the options assigned to it', () => {
const options = { name: '[hash]-[name].[ext]' };
const options = { name: '[hash]-[name].[ext]', esModule: false };
const instance = new FontConfigWebpackPlugin(options);

expect(instance.options).toEqual(options);
Expand Down
18 changes: 18 additions & 0 deletions packages/image-config-webpack-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,21 @@ module.exports = {
],
};
```

### Enable ES module syntax

By default the `image-config-webpack-plugin` uses the CommonJS modules syntax (`require` statements).
You can enable the ES module syntax (`import` statements) syntax using: `esModule: true` in the options.

For more information see [file-loader documentation](https://v4.webpack.js.org/loaders/file-loader/#esmodule)

```js
const ImageConfigWebpackPlugin = require('image-config-webpack-plugin');
module.exports = {
plugins: [
new ImageConfigWebpackPlugin({
esModule: true,
}),
],
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports = module.exports = (options) => ({
loader: require.resolve('file-loader'),
options: {
name: options.name,
esModule: options.esModule,
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports = module.exports = (options) => ({
options: {
name: options.name,
limit: 512,
esModule: options.esModule,
},
},
],
Expand Down
Loading