Skip to content

Commit

Permalink
docs: adds documentation around using additionalCode for disabling AMD
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrandpoobah committed Jul 7, 2020
1 parent afc1998 commit f71a9fb
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion README.md
Expand Up @@ -627,7 +627,11 @@ import $ from 'jquery';
Type: `String`
Default: `undefined`

Adds custom code.
Adds custom code as a preamble before the module's code.

##### Examples

###### Define custom variable

**webpack.config.js**

Expand Down Expand Up @@ -667,6 +671,47 @@ var myVariable = false;
// ...
```

###### Disable AMD Import Syntax

**webpack.config.js**

```js
module.exports = {
module: {
rules: [
{
test: require.resolve('example.js'),
use: [
{
loader: 'imports-loader',
options: {
imports: {
moduleName: 'jquery',
name: '$',
},
additionalCode:
'var define = false; /* Disable AMD for misbehaving libraries */',
},
},
],
},
],
},
};
```

Generate output:

```js
import $ from 'jquery';

var define = false; /* Disable AMD for misbehaving libraries */

// ...
// Code
// ...
```

## Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.
Expand Down

0 comments on commit f71a9fb

Please sign in to comment.