question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

unable to make file-loader to work

See original GitHub issue

Example webpackConfig part taken from my styleguide.config.js

webpackConfig: {
    context: path.resolve(__dirname, ""),
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            },
            {
                test: /\.(styl|stylus)$/,
                use: [
                    'style-loader',
                    'css-loader',
                    {
                        loader: 'stylus-loader',
                        options: {
                            import: [
                                path.resolve(__dirname, "../app/src/assets/stylus/globals.styl"),
                                resolve("src/styles/styles.styl"),
                            ]
                        }
                    }
                ]
            },
            {
                test: /\.svg$/,
                loader: "html-loader",
            },
            {
                test: /\.(ico|jpg|png)$/,
                loader: "file-loader",
            },
            { 
                test: /\.ts$/, 
                loader: 'ts-loader', 
                options: { 
                    appendTsSuffixTo: [/\.vue$/]
                } 
            },
            { 
                test: /\.tsx$/, 
                loaders: [
                    {
                        loader: "babel-loader"
                    },
                    {
                        loader: "ts-loader",
                        options: {
                            appendTsxSuffixTo: [/\.vue$/],
                            transpileOnly: true
                        }
                    }
                ]
            },
        ]
    },
    plugins: [new VueLoaderPlugin()],
    resolve: {
        extensions: ['.ts', '.tsx', '.js', '.vue', '.vuex', '.json'],
        alias: {
            "@": path.resolve(__dirname, "../app/src"),
        },
    }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
MacZelcommented, Feb 24, 2019

I was able to find a solution. file-loader and url-loader both work. To load a file you need to pass webpack rule:

{
    test: /\.(ico|jpg|png)$/,
    loader: "file-loader",     // or url-loader
},

create script at eg. loadImages.js. In this file you need to import every file:

import img_1 from './assets/image.png'
import img_2 from './assets/image.jpg'
import img_3 from './assets/image.ico'

then pass this script in Vue Styleguidist config file option require.

require: [
    resolve("loadImages.js"),
],

Dunno if this was obvious. Hope this will help somebody in the future.

Tested lots of other suggested solutions from SO and github issues, but this way only seems to work.

0reactions
elevatebartcommented, Feb 23, 2019

The only thig styleguidist does is using your webpack config to load the components. So if ti works without styleguidist it shoudl work with as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack url-loader or file-loader not working react app
I can see my file located in development build directory under subdirectory assets as I would expect. When running application on webopack dev ......
Read more >
file-loader - webpack - JS.ORG
The file-loader resolves import / require() on a file into a url and emits ... asset (`rootContext`) or `context` option // To get...
Read more >
Loading Fonts with webpack - Chris Courses
In this tutorial, I'll show you how to get fonts working with webpack and explain the minute details along the way to better...
Read more >
can't resolve 'file-loader' | The AI Search Engine You Control
In your case, App.js is in src/ directory while header.js is in src/components . To import you would do import Header from './components/header'...
Read more >
PGA900: File Loader: Verification failed: Values at ... - TI E2E
today I use uniflash download sW to PGA900 through XDS200 ... File Loader: Verification failed: Values at address 0x00000003 do not match ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found