Webpack raw loader from from public path?

837 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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')
    ]
}