Search code examples
node.jswebpackvue.jsvue-componentraw-loader

Webpack raw loader from from public path?


I am currently using the webpack raw loader to load a file like so:

import svg from '!!raw-loader!./../../public/images/svg/project/flag.svg';

I am using this with Vue.js and I would like to create a method, mixer or plugin to resolve automatically to my public path.

How can I make the raw loader start from the root of my project instead of building up a relative path?


Solution

  • Found the answer here:

    http://moduscreate.com/es6-es2015-import-no-relative-path-webpack/

    Added this to my webpack config, which now works fine:

    resolve: {
        modules: [
            path.resolve('./'),
            path.resolve('./node_modules')
        ]
    }