0.0.1 • Published 5 years ago
webpack-upload-loader v0.0.1
webpack-upload-loader
The webpack-upload-loader resolves import/require() on a file into a remote address
Getting Started
To begin, you'll need to install webpack-upload-loader:
$ npm install webpack-upload-loader --save-devImport (or require) the target file(s) in one of the bundle's files:
file.js
import img from './assets/logo.png';Then add the loader to your webpack config. For example:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'webpack-upload-loader',
},
],
},
],
},
};ℹ️ The current loader must be executed before
file-loaderandurl-loader
Options
esModule
Type: Boolean
Default: true
By default, webpack-upload-loader generates JS modules that use the ES modules syntax.
There are some cases in which using ES modules is beneficial, like in the case of module concatenation and tree shaking.
You can enable a CommonJS module syntax using:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader',
options: {
esModule: true,
},
},
],
},
],
},
};0.0.1
5 years ago