Any file in Meteor private directory app not work. ex:
myapp/
client/
server/
main.js
imports/
vnc.js
private/
bin/
x11vnc <-----
public/
in /server/main.js
import '/imports/vnc.js'
in /imports/vnc.js
import { Meteor } from 'meteor/meteor'
Meteor.startup(() => {
x11vncExecutavel = Assets.absoluteFilePath('bin/x11vnc');
})
the error is Error: Unknown asset: bin/x11vnc
https://docs.meteor.com/api/assets.html
Meteor version is 1.4.3.1
Related
Has anyone integrated Firebase Cloud Messaging with Svelte-Kit. My main issue is registering the firebase-messaging-sw.js. If placed in the static directory I get a 'Syntax Error for using import outside of a module'. I've tried adding the file to the src directory, and telling vite about it. My svelte.config.js looks like this.
import adapter from '#sveltejs/adapter-node';
import preprocess from 'svelte-preprocess';
/** #type {import('#sveltejs/kit').Config} */
const config = {
preprocess: preprocess(),
kit: {
adapter: adapter({
out: 'dist'
}),
csrf: {
checkOrigin: false,
},
files: {
serviceWorker: 'src/firebase-messaging-sw.js'
}
},
};
export default config;
I am testing using vite build && vite preview with no luck. I feel like i'm missing a simple config to keep the file at the root of the project.
The solution I found was to use 'importScripts' a service worker helper I wasn't aware of.
importScripts('https://www.gstatic.com/firebasejs/9.10.0/firebase-app.js');
importScripts('https://www.gstatic.com/firebasejs/9.10.0/firebase-messaging.js');
I'm attempting to have a folder called 'Uploads' in my vue public folder. However, whenever I build the project using npm run build. It removes all files from the public folder and rebuilds the project deleting any additional folders added. Is there any way I can tell the vue-config.js to leave a specific folder in the public folder?
const { defineConfig } = require('#vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true
})
const path = require('path');
module.exports = {
outputDir: path.resolve(__dirname, './server/public'),
devServer:{
proxy:{
'/api':{
target:'http://localhost:8080/api/posts/'
}
}
}
};```
I am trying to use matcher in my Next js middleware but documentation doesnt say much on how to implement the functionality.
All it shows is this without explaining which file it goes in or how to use the config in the middleware file:
export const config = {
matcher: '/about/:path*',
}
Does anyone have a working example of how to set up the matcher for a middleware file in Next js?
Thank you.
I was faced the same issue when learning this framework. I use nexjs v12.2.0.
to make middleware is running properly you need to put the middleware.ts or middleware.js in source directory and define the config matcher in it.
In Next.js 12.2 place a single file named middleware.ts within the root directory of your project (next to package.json):
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'
export function middleware (request: NextRequest) {
return NextResponse.next()
}
export const config = {
matcher: ['/api/hello/:helloId'],
}
1.Matching with config:
You have to export an object (Named export) named config from your middleware file :
middleware.js || middleware.ts
//middleware.js
export function middleware(request: NextRequest) {
return NextResponse.redirect(new URL('/about-2', request.url))
}
export const config = {
matcher: '/about/:path*',
}
2.File based Matching:
|-- pages/
│ ├── auth/
│ │ ├── index.js
│ │ └── middlware.js(1)
│ |
│ |── index.js
| |── middleware.js(2)
|__________________________
//middleware.js(1) will only run on /auth pages
//middleware.js(2) will run on all routes)
We are in need of a solution to compile SCSS and deploy to a remote server.
We have tried using both Grunt and Gulp setups but it appears that the FTP plugins for both are no longer compatible with newer versions of Grunt/Gulp.
We have also tried WebPack today which we like, but we're not sure how to deploy the compiled files.
We are needing to do it this way as it takes too long to download a copy of a clients site, make a small style change locally and reupload. We do want the benefits of using sass therefore we need a local solution to compile our styles and then deploy them to a specified folder on the server.
Our ideal workflow would be to make a change to a scss file (JS in the near future), a background task would see the change, compile it to css and another tasks would see that and deploy it to the correct remote folder.
Any ideas?
Thanks,
Neil
A small example of how you can recompile scss to css and upload to the server via ftp
Folder structure below and the normal call to node indes.js and that's it ;)
.
├── index.js
├── output.css
├── package.json
├── style.scss
└── yarn.lock
const fs = require('fs');
const sass = require('node-sass');
const ftp = require("basic-ftp")
const pathTotheFile = './output.css';
// compile scss
sass.render({
file: __dirname + './style.scss',
outputStyle: 'compressed',
outFile: __dirname + pathTotheFile,
// sourceMap: true,
}, function (error, result) {
if (error) {
console.log(error.status);
console.log(error.column);
console.log(error.message);
console.log(error.line);
} else {
console.log(result.stats);
fs.writeFile(pathTotheFile, result.css, function (err) {
if (!err) {
uploadCSStoServer();
}
})
}
});
// copy file to server
async function uploadCSStoServer() {
const client = new ftp.Client()
client.ftp.verbose = true
try {
await client.access({
host: "myftpserver.com",
user: "very",
password: "password",
secure: true
})
console.log(await client.list())
await client.uploadFrom("README.md", "README_FTP.md")
// await client.downloadTo("README_COPY.md", "README_FTP.md")
}
catch (err) {
console.log(err)
}
client.close()
}
I use import folder on my Meteor App, but I got error with following config :
/imports/startup/client/routes.js
import { FlowRouter } from 'meteor/kadira:flow-router';
import { BlazeLayout } from 'meteor/kadira:blaze-layout';
import '../../../ui/layout/layout.js';
import '../../../ui/pages/home/home.js';
FlowRouter.route('/', {
action: function() {
console.log("Yeah! We are on the post:");
}
});
and my /client/main.js
import '/imports/startup/client';
And I've this error :
Error: Cannot find module 'routes.js'
Do you have any idea why routes.js isn't loaded ?
Thank you !
You need to import the routes file. Your current import resolves to a folder so it will import the index file in the folder if there is one.