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.

Files from static folder not found in dev

See original GitHub issue

I seem to be having an issue where in dev mode my static files are not found.

To recap:

  • Vue-cli version: 2.9.1 (seems to include assetsPublicPath: '/', which seem to be an issue in previous vue versions)
  • files under static folder not found during npm run dev
  • within index.html I have following path: <script src="/static/scriptname.js"></script>

The built version does work!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
LinusBorgcommented, Dec 16, 2017

I will close this since there’s still no reproduction available And I can’t see what’s supposed to be wrong.

@goowikns Please open a new issue pointing to this one if you can create a repository that actually reproduces the issue

1reaction
nkovacscommented, Dec 16, 2017

I’m not sure if I ran into the same problem. I changed assetsSubDirectory to an empty string and that breaks static file serving.

Before you switched to using webpack-dev-server instead of your custom dev server, you had this: https://github.com/nickspiel/webpack/blob/b4b8154a7dbcc469069a94b017dc2d56a429e8f2/template/build/dev-server.js#L57 This worked fine because it was serving ./static as whatever you decided to rename your assetsSubDirectory to.

Now it doesn’t work any more because webpack serves all files in the working directory. The working directory is set to the project root when you start the dev server with npm run or yarn run, so your entire working directory is served by webpack-dev-server (see https://webpack.js.org/configuration/dev-server/#devserver-contentbase). This means that the default assetsSubDirectory only works because the source directory is also called static. As soon as you change assetsSubDirectory, it breaks. However, under e2e tests it works because it uses the production config and CopyWebpackPlugin. Using CopyWebpackPlugin in the dev config too instead of relying on contentBase fixes this problem, at least with assetsSubDirectory set to an empty string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django - Static file not found - Stack Overflow
Since I'm in a development environment, the solution for me is to not use STATIC_ROOT (or to specify another path) and set my...
Read more >
Static files in ASP.NET Core | Microsoft Learn
Static files are stored within the project's web root directory. The default directory is {content root}/wwwroot , but it can be changed with ......
Read more >
my static file not found - Using Django
my static folder: image. When I debug my django app on local host, “GET /static/rest_framework/js/ajax-form.js HTTP/1.1” 404.
Read more >
74 - Static Files in Development - Python & Django 3.2 Tutorial ...
74 - Static Files in Development - Python & Django 3.2 Tutorial Series Try Django 3.2 is a series to teach you the...
Read more >
How to manage static files (e.g. images, JavaScript, CSS)
In your templates, use the static template tag to build the URL for the given relative path using the configured STATICFILES_STORAGE . ......
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