Webpack动态需要加载器

时间:2016-08-31 09:08:08

标签: javascript webpack

我想导入一个.svg文件,并在使用加载程序导入时替换其中的一些文本。

import { PARKING_PIN_COLOR } from "styles/colors"

var path = "multiple-replace?COLOR=" + PARKING_PIN_COLOR + "!images/"
const PinParkingLotActive = require(path + "pin-parking-lot-active.svg")

但是这段代码在webdev服务器中给出了这个输出: [1292] ./src/map/internal/components ^.*pin\-parking\-lot\-active\.svg$ 160 bytes {0} [built]

当然,在运行时无法找到该文件。

Error: Cannot find module "."
    at webpackMissingModule (eval at <anonymous> (http://localhost:4000/bundle.js:11347:2), <anonymous>:112:71)
    at Object.eval (eval at <anonymous> (http://localhost:4000/bundle.js:11347:2), <anonymous>:112:149)
    at eval (eval at <anonymous> (http://localhost:4000/bundle.js:11347:2), <anonymous>:411:30)
    at Object.<anonymous> (http://localhost:4000/bundle.js:11347:2)
    at __webpack_require__ (http://localhost:4000/bundle.js:556:30)
    at fn (http://localhost:4000/bundle.js:87:20)
    at eval (eval at <anonymous> (http://localhost:4000/bundle.js:11320:2), <anonymous>:16:12)
    at Object.<anonymous> (http://localhost:4000/bundle.js:11320:2)
    at __webpack_require__ (http://localhost:4000/bundle.js:556:30)
    at fn (http://localhost:4000/bundle.js:87:20)

这些星座不受支持吗?

0 个答案:

没有答案
相关问题