Extending webpack module resolution path in Nuxt.js

Viewed 317

Does anyone have working examples of extending config.resolve.modules array in Nuxt.js? Here's the part of nuxt.config.js with changes:

const pathLib = require("path");

... 

build: {
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {
        config.resolve.modules.push(pathLib.resolve(__dirname, "./scss"));
    }
}

"./scss" directory holds style.scss file

Adding that file into the "Global CSS" array in nuxt.config.js produces an error:

Could not compile template /sandbox/node_modules/@nuxt/vue-app/template/App.js: Cannot resolve "style.scss" from "/sandbox/style.scss"

Seems that generated Nuxt webpack config just ignores the changes in config.resolve.modules.

Link to codesandbox: https://codesandbox.io/s/nuxt-modules-resolving-issue-ufnju

Any suggestions?

0 Answers
Related