Closed BotellaA closed 6 years ago
You may have to call config.module.rules.push
instead of config.module.rules.concat
.
Otherwise nothing get's added to the rules...
If I use push
I get this error:
ERROR
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.module.rules[11] should be an object.
-> A rule
Which also make sense...
vtkRules = [...];
a = [rule1, rule2];
a.push(vtkRules);
=> a = [rule1, rule2, [...]]
a.concat(vtkRules)
=> a same as before
Thanks for your quick answers. I tried several syntaxes but same error as in my first post.
config.module.rules = config.module.rules.concat(vtkRules)
config.module.rules.push(...vtkRules)
config.module.rules.push.apply(config.module.rules, vtkRules)
Sorry I am quite new at JS...
Try that then
config.module.rules.push({
test: /\.glsl$/i,
include: /vtk\.js(\/|\\)/,
loader: 'shader-loader',
});
config.module.rules.push({
test: /\.js$/,
include: /vtk\.js(\/|\\)/,
loader: 'babel-loader?presets[]=env',
});
config.module.rules.push({
test: /\.worker\.js$/,
include: /vtk\.js(\/|\\)/,
use: [
{
loader: 'worker-loader',
options: { inline: true, fallback: false },
},
],
});
Same result...
Maybe asking on nuxt how to add rules that you want to be applied to some /node_modules/...
path, could be a way forward.
I was looking for the shader-loader in my node_modules and it was not here. After a npm install
, I do not have the glsl error anymore. Probably there was an issue during a previous npm install
.
However, I have a new error...
nuxt:render Rendering url /vtk +54s
{ /home/botella/programming/arnaudbotella.bitbucket.io/node_modules/vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow/index.js:1
(function (exports, require, module, __filename, __dirname) { import macro from 'vtk.js/Sources/macro';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at r (/home/botella/programming/arnaudbotella.bitbucket.io/node_modules/vue-server-renderer/build.js:8330:16)
at Object.<anonymous> (server-bundle.js:20384:18)
at __webpack_require__ (webpack:/webpack/bootstrap f669670a10d24b06ee44:25:0)
at Object.53 (pages/vtk/index.vue?f967:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap f669670a10d24b06ee44:25:0)
at Object.49 (pages/vtk/index.vue:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap f669670a10d24b06ee44:25:0) statusCode: 500, name: 'SyntaxError' }
It seems to be both.
We use kw-web-suite in our dependencies to bring all the loaders and webpack infrastructure. But it is true that since you are using nuxt, you may have to add those loaders to your dependencies.
Regarding the macro error, this is definitely related to a missing rule to properly transpile the vtk.js code using babel with babel-preset-env (or else).
That was an issue on nuxt configuration. Now I get another error but probably caused by nuxt configuration again.
TypeError: Cannot set property console of #<Object> which has only a getter
at Object.exports.modules.Array.concat.Object.defineProperty.value (node_modules/vtk.js/Sources/macro.js:75:0)
at __webpack_require__ (webpack:/webpack/bootstrap 496a4d077853872728a6:25:0)
at Object.exports.modules.Array.concat.Object.defineProperty.value (node_modules/vtk.js/Sources/Rendering/Misc/FullScreenRenderWindow/index.js:9:0)
at __webpack_require__ (webpack:/webpack/bootstrap 496a4d077853872728a6:25:0)
at Object.exports.modules.Array.concat._vm (pages/vtk/index.vue?f967:10:0)
at __webpack_require__ (webpack:/webpack/bootstrap 496a4d077853872728a6:25:0)
at Object.exports.modules.Array.concat.vtkFullScreenRenderWindow.vtkFullScreenRenderWindow (pages/vtk/index.vue:1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 496a4d077853872728a6:25:0)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7) statusCode: 500, name: 'TypeError' }
Probably as that does not ring any bell on my end.
Thanks for your help
I am trying to use vtk-js inside a nuxt project but I encounter some issues. Do you have an example?
I am looking at your example with webpack but nuxt has different configuration files.
Here what I tried: