ray-external-loader
v1.0.0
Published
external url-loader file
Downloads
4
Readme
ray-external-loader
author
ilex.h
描述 descr
将 url-loader 或者 file-loader 加载的图片等资源,采用 require 的模式输出
Install
npm install -save-dev ray-external-loader
Usage
- App.js
import img from './image.png';
- webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.(png||jpe?g|gif|svg)$/i,
use: [
{
loader: 'ray-external-loader',
options: {
fallbackLoader: 'url-loader',
packageName: 'library-package-name', // your package name, 默认为 `.`, 此时 webpackConfig.output.publicPath = '';
enabled: process.env.NODE_ENV === 'production', // if you want to enable or disable ray-external-loader and fallback on url-loader
limit: 8192, // url-loader limit
}
}
]
}
]
}
};
output:
module.exports = require("./image.png");
Lecense
MIT