Files from static folder not found in dev
See original GitHub issueI 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:
- Created 6 years ago
- Comments:14 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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 yourassetsSubDirectory
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
oryarn 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 defaultassetsSubDirectory
only works because the source directory is also calledstatic
. As soon as you changeassetsSubDirectory
, 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 withassetsSubDirectory
set to an empty string.