Gab*_*ach 5 glsl webpack next.js
我正在尝试在我的 NextJS 应用程序中加载 GLSL 着色器。我已经像这样配置了我的 next.config.js :
module.exports = {
reactStrictMode: true,
images: {
domains: [
'localhost',
'backend.rolideluxe.ch'
]
},
webpack: ( config, {} ) => {
config.module.rules.push({
test: /\.mp4$/,
use: {
loader: 'file-loader'
}
})
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
use: {
loader: 'raw-loader'
}
})
return config
},
}
Run Code Online (Sandbox Code Playgroud)
这将返回错误(底部是着色器的着色器开始部分)
./public/shaders/blob/vertex.glsl
Module parse failed: Unexpected token (2:8)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
> uniform vec2 uFrequency;
Run Code Online (Sandbox Code Playgroud)
我对 NextJS 和 ThreeJS 比较陌生,对 Webpack 也没什么经验。我尝试过不同的加载器(例如 glsl-shader-loader 和 Shader-loader),但结果都相同。根据我收集的信息,错误应该在于 Webpack 和 NextJS 的交集处。因此我的两个问题:
小智 3
glslify-loader如果你安装并遵守规则,你就可以做到
/** @type {import('next').NextConfig} */
module.exports = {
reactStrictMode: true,
webpack: (config, options) => {
config.module.rules.push({
test: /\.(glsl|vs|fs|vert|frag)$/,
use: ['raw-loader', 'glslify-loader'],
});
return config;
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3930 次 |
| 最近记录: |