Когда я делаю require("!!raw-loader!themes/builtin_themes/default/layout.json")
, я получаю следующую ошибку:
Module parse failed: Unexpected token m in JSON at position 0 while parsing near 'module.exports = "{\...'
File was processed with these loaders:
* ../node_modules/raw-loader/index.js
You may need an additional loader to handle the result of these loaders.
SyntaxError: Unexpected token m in JSON at position 0 while parsing near 'module.exports = "{\...'
at JSON.parse (<anonymous>)
at parseJson (/Users/frederikcreemers/dev/project/node_modules/json-parse-better-errors/index.js:7:17)
at JsonParser.parse (/Users/frederikcreemers/dev/project/node_modules/webpack/lib/JsonParser.js:16:16)
at /Users/frederikcreemers/dev/project/node_modules/webpack/lib/NormalModule.js:482:32
at /Users/frederikcreemers/dev/project/node_modules/webpack/lib/NormalModule.js:358:12
[w-renderer] at /Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:373:3
at iterateNormalLoaders (/Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
at iterateNormalLoaders (/Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
at /Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:236:3
at runSyncOrAsync (/Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
at iterateNormalLoaders (/Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
at Array.<anonymous> (/Users/frederikcreemers/dev/project/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
at Storage.finished (/Users/frederikcreemers/dev/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
at /Users/frederikcreemers/dev/project/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
at /Users/frederikcreemers/dev/project/node_modules/graceful-fs/graceful-fs.js:90:16
at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:61:3)
У нас есть загрузчик json, настроенный следующим образом:
{
test: /\.json$/,
use: [{
loader: "json-loader",
options: { context: "." }
}]
}
, но я понял, что "!!" впереди отключит все настроенные загрузчики.
Если возможно, я бы хотел оставить конфигурацию webpack в покое и просто изменить инструкцию require, чтобы это работало.