Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
updates for 4.19
Browse files Browse the repository at this point in the history
  • Loading branch information
odoe committed Apr 19, 2021
1 parent 1a42e3a commit 231851f
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 65 deletions.
45 changes: 0 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ For version 4.17 and lower, please see [this documentation here](https://github.
* [Features](#features)
* [Options](#options)
* [Usage](#usage)
* [Asset Loaders](#asset-loaders)
* [Additional Features](#additional-features)
* [Issues](#issues)
* [Contributing](#contributing)
Expand Down Expand Up @@ -69,50 +68,6 @@ module.exports = {
}
```

## Asset Loaders

By default, this plugin provides provides [url-loader](https://github.com/webpack-contrib/url-loader) for images and [file-loader](https://github.com/webpack-contrib/file-loader) for assets that are only used by the ArcGIS API for JavaScript. However, if you are using another library that you need to load image, svg, or fonts for, you will want to provide your own loaders. You will want to set the `useDefaultAssetLoaders` to `false`.

```js
// webpack.config.js
...
plugins: [
new ArcGISPlugin({
// disable provided asset loaders
useDefaultAssetLoaders: false
})
],
...
```

Then you can provide your own asset loaders.

```js
// webpack.config.js
...
module: {
rules: [
...
{
test: /(@arcgis\/core|arcgis-js-api)([\\]+|\/).*.(jpe?g|png|gif|webp)$/,
loader: "url-loader",
options: {
// Inline files smaller than 10 kB (10240 bytes)
limit: 10 * 1024,
}
},
{
test: /(@arcgis\/core|arcgis-js-api)([\\]+|\/).*.(ttf|eot|svg|png|jpg|gif|ico|wsv|otf|woff(2)?)(\?[a-z0-9]+)?$/,
use: [
"file-loader"
]
}
]
}
...

```

## Additional Features

### Excluding modules
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@arcgis/webpack-plugin",
"version": "4.19.0-next20210225",
"version": "4.19.0-next20210419",
"description": "Webpack plugin to load ArcGIS API for JavaScript into a Webpack application",
"main": "index.js",
"engines": {
Expand Down
1 change: 0 additions & 1 deletion test/support/configs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const path = require("path");

const defaultOptions = {
useDefaultAssetLoaders: true,
features: {
"3d": true
},
Expand Down
20 changes: 2 additions & 18 deletions test/unit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,6 @@ describe("Initialize ArcGIS webpack plugin", () => {
expect(plugin.options).to.deep.equal(defaultOptions);
});

it ("will add modules to webpack compiler", () => {
const plugin = new ArcGISWebpackPlugin();
const compiler = createCompiler();
plugin.apply(compiler);
expect(compiler.options.module.rules).to.have.lengthOf(2);
});

it ("will not use default loaders given useDefaultAssetLoaders = false", () => {
const plugin = new ArcGISWebpackPlugin({
useDefaultAssetLoaders: false
});
const compiler = createCompiler();
plugin.apply(compiler);
expect(compiler.options.module.rules).to.have.lengthOf(0);
});

it ("will use null-loader to exclude 3D modules given exclude3D = true", () => {
const plugin = new ArcGISWebpackPlugin({
features: {
Expand All @@ -43,7 +27,7 @@ describe("Initialize ArcGIS webpack plugin", () => {
});
const compiler = createCompiler();
plugin.apply(compiler);
expect(compiler.options.module.rules).to.have.lengthOf(3);
expect(compiler.options.module.rules).to.have.lengthOf(1);
});

it ("will use null-loader to exclude user defined modules given userDefinedExcludes = true", () => {
Expand All @@ -52,6 +36,6 @@ describe("Initialize ArcGIS webpack plugin", () => {
});
const compiler = createCompiler();
plugin.apply(compiler);
expect(compiler.options.module.rules).to.have.lengthOf(3);
expect(compiler.options.module.rules).to.have.lengthOf(1);
});
});

0 comments on commit 231851f

Please sign in to comment.