knpwrs / vue-node

Load vue components in node.
MIT License
61 stars 5 forks source link

issue with resolve.path #11

Open peteringram0 opened 7 years ago

peteringram0 commented 7 years ago

There seems to be an issue with alias when using vue-node. If i do a console.log on '~vue' inside my application it resolves however when running through vue-node and ava it reports "Cannot find module '~vue'" even though the paths seem correct.

const path = require('path');

module.exports = {
    resolve: {
        alias: {
            '~vue': 'vue/dist/vue.min',
        }
    },
    module: {
        rules: [{
            test: /\.vue$/,
            loader: 'vue-loader',
        }],
    },
};
knpwrs commented 7 years ago

You might want to take a look here: https://github.com/knpwrs/vue-node/blob/1f348e97aafba000354470a58709b77fbe6a2548/lib/compiler.js#L34-L42

Basically if resolved is specified, I assume that the end user knows what they are doing. You probably have to add node_modules back in.

peteringram0 commented 7 years ago

Thanks @knpwrs not sure im following correctly though. Are you able to give an example of how my config above should look for alias's to work?

Thanks

peteringram0 commented 7 years ago

I have tried the following with no luck. If i ref ~vue from an import it will not find it.

const path = require('path');

module.exports = {
    resolve: {
        extensions: [".js", ".json", '.vue'],
        modules: [path.resolve(__dirname, "src"), "node_modules"],
        alias: {
            '~vue': 'vue/dist/vue.min',
        }
    },
    module: {
        rules: [{
            test: /\.vue$/,
            loader: 'vue-loader',
        }],
    },
};