You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, `raw-loader` generates JS modules that use the ES modules syntax.
70
+
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
71
+
72
+
You can enable a CommonJS module syntax using:
73
+
74
+
**webpack.config.js**
75
+
76
+
```js
77
+
module.exports= {
78
+
module: {
79
+
rules: [
80
+
{
81
+
test:/\.txt$/i,
82
+
use: [
83
+
{
84
+
loader:'raw-loader',
85
+
options: {
86
+
esModule:false,
87
+
},
88
+
},
89
+
],
90
+
},
91
+
],
92
+
},
93
+
};
94
+
```
95
+
62
96
## Examples
63
97
64
98
### Inline
@@ -70,7 +104,7 @@ import txt from 'raw-loader!./file.txt';
70
104
Beware, if you already define loader(s) for extension(s) in `webpack.config.js` you should use:
71
105
72
106
```js
73
-
importcssfrom'!!raw-loader!./file.css'; // Adding `!!` to a request will disable all loaders specified in the configuration
107
+
importcssfrom'!!raw-loader!./file.txt'; // Adding `!!` to a request will disable all loaders specified in the configuration
0 commit comments