webpack中装载程序的别名

时间:2015-08-06 16:34:18

标签: javascript webpack

是否可以在webpack中为加载器分配别名?

用法:

image: function(opts) {
  return "image-size?name=[name]-[hash:8].[ext]"
}
css: function(opts) {
  return "style?singleton!css?sourceMap&module&localIdentName=[path][name]_[local]_[hash:base64:6]!postcss"
}

我知道这是如何使用文件扩展名,并且可能成为不必要的实体。

我正在寻找一个解决方案,我希望能够编写一个长加载器,并且在使用require时只能使用一个选项。

说,

require('./file1.png?size=10')
require('./file2.png?size=15')

// at one place require it as component
// passing through a set of loaders
var Component = require('react-svg!./image.svg')
// and in another require it as data-uri
// passing through a different set of loaders
var imagestr = require('data-uri!./image.svg')
// and in css
url( image!./image.svg )

0 个答案:

没有答案
相关问题