I'm getting broken index.html after vuepress build docs with lots of Failed to load resource: net::ERR_FILE_NOT_FOUND in console.
vuepress dev docs, however, works totally fine!
My steps:
Created new project with vue-cli 3;
Made yarn add -D vuepress;
Added folders and files:
-docs
|
--.vuepress
| |
| --config.js
|
--guides
| |
| --README.md
--info
| |
| --README.md
|
--README.md
My config.js:
module.exports = {
title: 'Hello VuePress1',
description: 'Just playing around',
themeConfig: {
nav: [
{ text: 'Home', link: '/' },
{ text: 'Guide', link: '/guide/' },
{ text: 'Вернуться в приложение', link: '/desktop/' }
],
sidebar: [
'/',
'/guides/',
'/info/'
]
}
}
Now, vuepress dev docs gives at localhost:8080 exactly what i expect - everything is fine.
vuepress build docs generates dist folder, which contains:
assets folder
guides folder
info folder
404.html
index.html
Problem arises on opening index.html. Everything is displayed without CSS and links are not working. Seems like problems with paths to assets...
Why everything doesn't work properly out of the box in a completely new project?
The paths to the CSS and JS files in index.html are absolute (starts with /), so viewing index.html using the file protocol doesn't work (you need to host it on a server so the HTTP protocol are used).
you must run http server to open this file.
open cmd in this folder, and run:
with python: python -m http.server
with nodejs:
Install http-server by typing npm install -g http-server
Change into your working directory, where yoursome.html lives
Start your http server by issuing http-server -c-1
Related
I have a nooby Directus question :
How to create an endpoint and attach it to my project ?
I try to follow the doc in vain :
Create a directus project
npm init directus-project example-project
SQLite / Admin / Password
cd example-project; npx directus start
I can access directus admin at http://0.0.0.0:8055/admin/content
CTRL+C
Create an endpoint
cd .., going away of my directus project, npm init directus-extension
endpoint / demo-directus-endpoint / javascript
Modifying endpoint / to /hello in src/index
cd demo-directus-endpoint; npm run build
Deploy extensions inside directus project
https://docs.directus.io/extensions/creating-extensions/
To deploy your extension, you have to move the output from the dist/ folder into your project's ./extensions/<extension-folder>/<extension-name>/ folder. <extension-folder> has to be replaced by the extension type in plural form (e.g. interfaces). <extension-name> should be replaced with the name of your extension.
cd ../example-project
mkdir ./extensions/endpoints/demo
cp -R ../demo-directus-endpoint/dist/index.js ./extensions/endpoints/demo
index.js looks like this :
"use strict";module.exports=e=>{e.get("/hello",((e,l)=>l.send("Hello, World!")))};
npx directus start
17:43:40 ✨ Loaded extensions: demo
17:43:40 ⚠️ PUBLIC_URL should be a full URL
17:43:40 ⚠️ Spatialite isn't installed. Geometry type support will be limited.
17:43:40 ✨ Server started at http://0.0.0.0:8055
Trying to get url http://0.0.0.0:8055/hello
curl http://0.0.0.0:8055/hello => {"errors":[{"message":"Route /hello doesn't exist.","extensions":{"code":"ROUTE_NOT_FOUND"}}]}
17:43:55 ✨ request completed GET 404 /hello 8ms
What to do in order to get Hello, World! when curl http://0.0.0.0:8055/hello ?
Thank you for your help
Answer found
curl http://0.0.0.0:8055/demo/hello => Hello, World!
We store our configurations on the vault and during the Github action workflow we pull this and intend to use this for the app during build time.
This is our workflow
- name: Get app configs from vault
env:
ENVIRONMENT: development
run: |
chmod +x scripts/ci/get-app-configs.sh
scripts/ci/get-app-configs.sh
echo "action_state=yellow" >> $GITHUB_ENV
- name: Set .env to process.env of github actions
uses: cardinalby/export-env-action#v1
with:
envFile: '.env'
expand: 'true'
- name: Generate APK
env:
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
run: |
echo "${{ env.action_state }}"
echo ${{ env.FIREBASE }}
eas build --platform android --local --profile development --non-interactive
The Get app configs from vault step creates an .env file with the following contents
FIREBASE={firebase_config_string}
And then inside firebase.ts we do this.
const firebaseConfig = JSON.parse(process.env.FIREBASE as string) as FirebaseOptions;
The app works fine when testing on an emulator but when testing the actual APK on a physical device, it always crashes. And in the logcat I keep seeing this error E AndroidRuntime: com.facebook.react.common.JavascriptException: SyntaxError: JSON Parse error: Unexpected identifier "undefined", stack:.
I've already narrowed it down to the firebase.ts process.env since the app doesn't crash when the config is hard coded.
I can see the env.FIREBASE as an env variable inside the Generate APK step so it's being passed to other steps fine. And the echo also prints out the value fine.
Is it not possible to access the env variables of Github action within the code during build time? Or are there other ways to achieve this?
Kept the github workflow as it is.
Fixed by using expo-constants.
Renaming the app.json to app.config.js to be able to add the following lines:
import 'dotenv/config';
export default {
expo: {
extra: {
ENV_VAR: process.env.ENV_VAR,
},
},
};
And access the said variable from the app by
import Constants from 'expo-constants';
const ENV_VAR = Constants.manifest?.extra?.ENV_VAR
I'm currently building a Vue.js app using vue/cli-service#4.5.17.
The issue I'm having is that whenever I change a .vue file, the server does not recompile, restart, or do anything.
I use this command (through package.json) to run the server in development environment:
NODE_ENV=development vue-cli-service serve
My vue.config.js file is:
module.exports = {
devServer: {
host: 'localhost',
port: 8080,
hot: true
},
publicPath: '/'
}
This is the output, and it does not change if I edit a file while the server is running:
DONE Compiled successfully in 17169ms 12:01:45 PM
App running at:
- Local: http://localhost:8080/
- Network: http://localhost:8080/
Note that the development build is not optimized.
To create a production build, run npm run build.
EDIT: I would like to add that a friend who is working on the same project and who start the server the same way as I do has the expected watch/reload feature. Is there a hidden environment variable to set or something?
I also would like to add that I'm using WSL2 to start the development server.
Thanks for your help!
Ok, I found something.
This is an issue with WSL2 not being able to trigger file change notifications: https://github.com/microsoft/WSL/issues/4739 .
I tried using Vite and with adding:
server: {
watch: {
usePolling: true
}
}
To the vite.config.js, it does work properly with WSL2 as explained here.
I am trying to change the logo following: https://doc.oroinc.com/frontend/storefront/how-to/how-to-replace-the-logo/ . I followed the steps to create an empty bundle, the bundle shows up in the symfony "active bundles" list so it seems to have registered correctly.
The theme definition in: Resources/views/layouts/my_theme/theme.yml :
label: My Theme
logo: bundles/companytheme/my_theme/images/mainlogo.svg
parent: default
groups: [ commerce ]
also seems to work, the "My Theme" is available in the backend>System>Configuration>Commerce>Design>Theme
But the logo doesn't work, there is just nothing. So I looked into public/bundles/ and noticed there is no symlink to the Resource files of my bundle.
Running
php bin/console assets:install --symlink
works, but it only shows the symlinks that are already there
Firstly make sure that you put your logo image into public folder like:
NEW_BUNDLE/package/Resources/public/img/logo.svg/.
Then add a logo property with value from public folder: bundles/NEW_BUNDLE/images/mainlogo.svg into theme.yml and clear the application cache and rerunning the command:
rm -rf var/cache/*
php bin/console assets:install --symlink
I am complete beginner so I apologize in advance.
I have installed npm with these scripts in terminal
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
then I set it to run like this
http-server -a localhost
Starting up http-server, serving ./public
Available on:
http://localhost:8081
an I have an index. html in my documents that I would like to display. I have tried to just state the whole path in the browser so like http://localhost:8081/Documents/testServer/index.html
But that doesn't work
You must install the tools inside the folder that contains index.html file as below
First : Open the folder that contain index.html
Second : Install Tools
1.curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
2.nvm install node
Third : Open the live server at :
http://localhost:8081/Documents/testServer/index.html