-
-
Notifications
You must be signed in to change notification settings - Fork 980
Module build failed: Error: the "basedir" option is required to use includes and extends with "absolute" paths #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You can read about pathing in Vue here: |
@woothu How can link above answer my original question:
According to docs:
Great, I can include my pug mixin using relative path:
Okay, this looks good. But you are supposed to configure base dir as the error message suggests in order to include pug file with absolute path. Would it help if I created a minimal project to reproduce the error? |
I am sorry, I didn't understand your issue correctly. Vue CLI 3 options config have changed, now you have to put config in vue.config.js file. (docs: https://cli.vuejs.org/guide/css.html#passing-options-to-pre-processor-loaders) I hope that helps :) P.S. I think this might be helpful for you to read: vuejs/vue-loader#472 |
Hey there, I'm having the same issue with Vue v3.3. What's the solve here exactly? I know I need to add the
Here's what I have so far in const path = require('path');
module.exports = {
css: {
loaderOptions: {
sass: {
data: `
@import "@/sass/_variables.sass";
@import "@/sass/_globals.scss";
`
}
}
},
chainWebpack: config => {
config.resolve.alias
// attempt to set an alias to resolve the path doesn't work
.set("@pug", path.resolve(__dirname, "./src/pug"));
// something like this?
config.rules.pug.options.basedir = path.resolve(__dirname, "./src/pug");
},
pluginOptions: {
// this doesn't seem to work either
pug: {
basedir: path.join(__dirname, 'src/pug')
}
}
} @woothu any ideas? I appreciate your help on this =) |
Did you try vue-cli-plugin-pug? It is possible that it will set config automatically. |
I seem to be missing something but can't quite figure out what.. my vue.config.js const path = require('path');
const srcPath = path.resolve(path.dirname(__filename), 'src');
module.exports = {
chainWebpack(config) {
config.resolve.alias.delete('@');
config.resolve
.plugin('tsconfig-paths')
.use(require('tsconfig-paths-webpack-plugin'));
// Pug Loader
config.module
.rule('pug')
.test(/\.pug$/)
.use('pug-plain-loader')
.loader('pug-plain-loader')
.options({basedir: srcPath})
.end();
},
};
/* config.module.rule('pug') */
{
test: /\.pug$/,
oneOf: [
/* config.module.rule('pug').oneOf('pug-vue') */
{
resourceQuery: /vue/,
use: [
/* config.module.rule('pug').oneOf('pug-vue').use('pug-plain-loader') */
{
loader: '/Users/sam/Projects/vue-test/node_modules/pug-plain-loader/index.js'
}
]
},
/* config.module.rule('pug').oneOf('pug-template') */
{
use: [
/* config.module.rule('pug').oneOf('pug-template').use('raw') */
{
loader: 'raw-loader'
},
/* config.module.rule('pug').oneOf('pug-template').use('pug-plain-loader') */
{
loader: '/Users/sam/Projects/vue-test/node_modules/pug-plain-loader/index.js'
}
]
}
],
use: [
/* config.module.rule('pug').use('pug-plain-loader') */
{
loader: 'pug-plain-loader',
options: {
basedir: '/Users/sam/Projects/vue-test/src'
}
}
]
}, but still getting error: Module build failed (from ./node_modules/pug-plain-loader/index.js):
Error: the "basedir" option is required to use includes and extends with "absolute" paths Looks like I need to also get the options in the |
Figured it out, for anyone hitting the same issue. added -> config.module
.rule('pug')
.test(/\.pug$/)
.oneOf('pug-vue')
.use('pug-plain-loader')
.loader('pug-plain-loader')
.options({basedir: srcPath})
.end();
config.module
.rule('pug')
.test(/\.pug$/)
.oneOf('pug-template')
.use('pug-plain-loader')
.loader('pug-plain-loader')
.options({basedir: srcPath})
.end(); to |
I am trying to use pug as template lang but getting an error when including the mixins.
Error says:
Module build failed: Error: the "basedir" option is required to use includes and extends with "absolute" paths
Where am I supposed to configure the basedir option?
I have installed the pug using
npm install pug --save-dev
My Login.vue looks like this now:
Works fine, when I don't use include.
The text was updated successfully, but these errors were encountered: