Where should I place uploads dir in Nuxt.js project? - vue.js

I had my uploads directory in a root, but to reach images inside the directory I had an api created.
Now the same but better solution would be to have this directory in a static/ so I could reach the images throught the link easily.
Another option would be placing it inside assets/ dirrectory and require() the image.
Which one is recommended and would be best solution?

Related

Images uploaded in Vue.js production mode not showing

I am a bit new to Vue.js. I am doing a social media application that allows users to upload and share images with others. I store my images in src/assets folder during development. However, when I build the project, all images are put in the dist folder. Therefore, what can I do to enable users to still upload images on production? Do I create the assets directory in the dist folder?
I have since tried different ways, including storing images on the backend. In dooing this, I reference the backend path relatively, using, for example, ../../../backend/public/assets..., and it works on development. However, when I build, the images that existed in the backend directory at the time of building are visible, however, whenever I try uploading more on production to the ../../../backend/public/assets... directory, they are uploaded successfully but are not visible (that is on production). I get an error that Cannot find module './image_name.image_extension'.
What am I doing wrong?
I have seen similar questions like this but there was no answer.
You must set your public path and change your way!!
first step to do is creating vue.config.js in your root directory, if you want to know more details, read this: https://cli.vuejs.org/config/
for example, I define prefix path for my files:
module.exports = {
publicPath:
process.env.NODE_ENV === "production" ? "/" : "/",
};
remember, It's better if you use "#" to define your paths.
for example, if you want to load a image which located in src/assets/files/img/myImage.png, you can use #/assets/files/img/myImage.png in template section for binding or script section of your .vue files!
It always help you to find correct path of your files.
and finally your way is not standard because "src/assets/..." will used for compiled scripts and styles and also your files which you want to use on your UI layout like static images. so you have to use "public/assets/..." directory to save your file, then you will see everything is going well for you.
if you have a more question or stuck solving this problem again, I'm here to fix your issues.

How to generate txt & xml files in nuxt SSR?

Is there any way of generating a Google : ads.txt file every time i build my SSR project?
There is a module called: sitemap-module from nuxt-community, it is used to generate a sitemap xml file, and that file can be accessed by http://domain.tls/sitemap.xml. and i want something like that.
So currently i'am achieving this by building the project, then manually put ads.txt it in : /var/www/site/.nuxt/dist/client/,
The problem with this is that everytime i rebuild the project i loose /var/www/site/.nuxt/dist/client/ folder then i have to add ads.txt file again.
I would like to know how i can hook up my code to tell nuxt to generate ads.txt file and put it in /var/www/site/.nuxt/dist/client/
Not sure if it makes sense, but i hope someone will understand.
Place your ads.txt file in a directory named static as mentioned here. All the contents of the static directory can be accessed via example.com/{filename.extension}
If you are not using nuxt.js and just using vue js, place it in a public directory right next to src directory.
Haven't found any way of solving this in nuxt, so i decided to redirect all https://domain.tld/ads.txt in Nginx configuration.
/etc/nginx/sites-available/default.conf
#redirect all txt request
location ~* ^.+.(txt)$ {
root /var/www/other.files/;
}
So i think i'll stick to it.

Shopify Use Subdirectory in Asset Folder

Instead of putting all files in a place in the asset folder, I want to use CSS files in CSS folder, JS files in js folder and images in images folder. Then Include them in the asset folder, so that I can maintain the files easily.
I know Shopify doesn't support any sub-directories within the asset folder. But is there any trick to do that?
According to a Shopify employee. This is currently not possible and the reason is due to a limitation of the CDN they use. See that post here.
Regardless, it's not good practice to have source files in the assets folder. Look into the Shopify Slate tool. It's a theme scaffold and command line interface that helps keep your project structure organized.
You can organize your assets (both CSS and JavaScript) as source files with directory structures in a manner similar to this:
styles/
global/
modules/
settings
tools/
vendor/
The command line tool takes care of compiling all the source files into one CSS/JS file! As a consequence, you don't need to worry about including the respective files with <link> or <script> tags because it's all taken care of already!
Unfortunately, this is not something currently supported by Shopify (As of 14/Sept/2017)
I tried making sub-folders both at the root of my dev theme and in the asset folder of my dev theme in a few different ways, including through Shopify's ThemeKit editor, but Shopify did not let me create the folder.
Attempting to create sub-folders in the normal theme editor in the store (by naming an asset subfolder/filename) generates the error message: Theme files may not be stored in subfolders
Shopify's normal theme editor groups files by types so that they appear close together, and apparently that's as much as Shopify is giving us right now.

aurelia bundle - serve from a single directory

Trying to use the aurelia cli bundling facility.
Is it possible to serve all app files (i.e. index.html, app-bundle.html, app-bundle.js, etc) from a single directory or index.html must be at the top (./) directory and the other files in a child (./dist) directory?
Under the covers the cli is using JSPM / System.js's bundling functionality. This works by looking at your config.js paths on where to find the files both for the bundle and when serving. If your paths are set up to serve from the root directory this should work as expected. The problem will be that if you are trying to bundle root it will try to grab all .js files in there which could be bad if you don't exclude them.

Changing Inside Assets Folder In Yii Framework

I came to notice that there is one folder called assets in the root folder.To know more about it,I went through this link.Now I want to know adding some css in these files is good or shall I add css to to the main.css file inside css folder.
The asset folder is automatically generated by Yii based upon your environment so best avoid putting your CSS, images etc inside here. It also best to not commit these folders and files into SVN as they are automatically generated and folder names will differ from your qa/staging/live site to your local site.
There are some good reasons to use Yii's assets.
it prevents naming conflicts in css and js files
it allows you to keep CSS and JS files under your document-root but outside of your web-root (for easier version control)
it allows to easily switch between sets of CSS & JS files, rather than having to deal with each file individually (suppose the system admin needs to revert back to a previous version).
it allows you to publish assets (images, JS & CS) to several websites hosted on the same server.
Please check here or there for more details.
Well, when i started my first Yii project, i also put my CSS and JS files in assets. It works but then i found that its not just the right way. Its better to make a separate directory for your CSS file(s). Also there are some auto generated files in assets, so to avoid mix-up with those and your i prefer to make it separate. Hope you got the point.