[英]Custom files inside modules import using Angular
Trying to move from old architecture to the modular world and using the posprocessing package from npm with Three and Angular. 尝试从旧架构过渡到模块化世界,并使用npm中的posprocessing软件包以及Three和Angular。
When importing a module from postprocessing it gives the following error: 从后处理导入模块时,会出现以下错误:
Failed to compile.
./~/postprocessing/src/materials/adaptive-luminosity/glsl/shader.frag
Module parse failed: (...)/materials/adaptive-luminosity/glsl/shader.frag Unexpected token (1:8)
You may need an appropriate loader to handle this file type.
| uniform sampler2D tPreviousLum;
| uniform sampler2D tCurrentLum;
| uniform float minLuminance;
@ ./~/postprocessing/src/materials/adaptive-luminosity/index.js 3:0-42
@ ./~/postprocessing/src/materials/index.js
I assume its something with the Angular cli settings. 我认为它与Angular cli设置有关。 Any idea how to enable the importing of custom file extensions?
任何想法如何启用自定义文件扩展名的导入?
Seems like you are trying to import a webgl fragment. 似乎您正在尝试导入webgl片段。 Full disclosure, I don't know much about them.
完全公开,我对他们了解不多。 However, the issue is that webpack (config hidden in angular-cli) does not have a loader to handle the file type you want to import
.frag
但是,问题是webpack(隐藏在angular-cli中的配置)没有加载程序来处理您要导入的文件类型
.frag
read on loaders here: https://webpack.js.org/concepts/loaders/ 在此处阅读加载程序: https : //webpack.js.org/concepts/loaders/
here is what you can do, if you really wish to use angular-cli 如果您确实希望使用angular-cli,可以执行以下操作
glslify-loader
to webpack config: https://github.com/stackgl/glslify-loader glslify-loader
添加到webpack配置中: https : //github.com/stackgl/glslify-loader from the glslify-loader
doc: 从
glslify-loader
文档中:
npm install --save glslify-loader raw-loader
then in loaders
section of the webpack config file, add: 然后在webpack配置文件的
loaders
部分中,添加:
loaders: [
{ test: /\.(glsl|frag|vert)$/, loader: 'raw', exclude: /node_modules/ },
{ test: /\.(glsl|frag|vert)$/, loader: 'glslify', exclude: /node_modules/ }
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.