I am using the following base for a Backbone Marionette application: link
When I run $ brunch watch --server it is working fine on localhost:3333 . However, it is not working from my iPhone browser (on same WiFi) via 192.168.x.x:3000 . Another project using gulp and Browser Sync is showing up on the iPhone browser using same strategy.
Now, I have two questions:
1. Is there a way to test a site being served by basic brunch dev server on a mobile device ? [Solved now! Please refer to the comment below.]
2. This seems to be an even more serious issue, if I take the public folder (where the built output is supposed to go) and put it inside an Apache document root, the site is not working and just shows a blank page with no console errors. There doesn't seem to be any file access permissions issue etc.
What is the right way to deploy this app now ?
Here is my brunch config.coffee:
exports.config =
# See http://brunch.io/#documentation for docs.
files:
javascripts:
joinTo:
'javascripts/app.js': /^app/
'javascripts/vendor.js': /^(bower_components|vendor)/
stylesheets:
joinTo:
'stylesheets/app.css': /^(?!test)/
order:
after: ['vendor/styles/helpers.css']
templates:
joinTo: 'javascripts/app.js'
Related
I'm trying to learn how to deploy a Stencil web app using a web server like Ngnix but I can't make it work on localhost. I suspect there is no entry point for the minified build.
As an example, I'm using the stencil starter app.
In my stencil.config.ts file, I have opted-in for the "dist" output target.
outputTargets: [
{
type: 'www',
// comment the following line to disable service workers in production
serviceWorker: null,
baseUrl: 'https://myapp.local/',
},
{
type: 'dist'
},
]
For the minified build I am running the command:
npm run build -production
The generated "/dist" folder does not contain an index.html file and this prevents me from being able to serve it using Ngnix.
The contents of the dist folder
I would expect that the generated "/dist" folder would contain an "index.html" file that could be served as an entry point to a web server.
What am I doing wrong?
Is there anything I'm missing?
The dist output target is meant for including in existing pages.
To generate a website you can use the www output target (in the www folder). This will also give you access to website-specific options, like a service worker.
The docs state:
The www output target type is oriented for webapps and websites, hosted from an http server, which can benefit from prerendering and service workers, such as this very site you're reading.
For anyone who comes across this in the future, I found the solution.
I was supposed to use the "/www" folder for deployment as that's the way it's supposed to work for standalone web apps, and it contains an "index.html" file.
Here is the documentation
to preface: Im running a vue / spring webapp. My application on localhost runs under
"localhost:8080/application/"
while on DEV and TEST it runs under http://application-dev/ and http://application-test/ - so the /application prefix is missing.
In my sass I have the following image url paths: url("/application/image.png")
And on the DEV and TEST webservers I made redirects from /application to / to have it find the images.
Now I want to remove the "/application" part from my images and still get it to work on localhost.
Is there any way I can have a variable in my sass like "{contextpath}/image.png" and let the Spring webapp fill in the contextpath depending on where its deployed? So if I deploy at localhost the path would be ="/application" and if I deploy on test it would need to be equal to an empty string.
Is this even possible? tyvm
I recently used Google's Firebase to deploy my application. But somehow something is going wrong. Please access the below link to view the exact error trace.
In my build, everything looks normal all the CSS files and JS files have the appropriate code but after the deployment all the Files have HTML, go through the Below URL and watch the console to have a better idea of the error.
https://workout-wfh.web.app/
View both Images to view the difference :
1. In the deployed application
In my local build
If you view the source of the deployed website, you'll see that the <script> tag is trying to load this URL:
https://workout-wfh.web.app/MohanVarma1965/workout.git/static/js/main.5cca3537.chunk.js
which doesn't exist and so is falling back to your default HTML content. It looks like your build process is generating absolute URLs that include your username and directory path. You should adjust your build tooling to leave out everything before /js.
I have a pre-compiled ember.js app (which fronted-js-framework shouldn't matter here), which basically consists of a folder with a index.html file, and a few js/css assets.
I placed this folder under /priv/static in my phoenix app, and tried to get the routing to serve it... without success so far. I'm on phoenix version 0.17.1 (same as 1.0 afaik). I tried the following steps, in that order:
In endpoint.ex, I removed the only: ~w(...) filter.
Implemented a bare minimum controller with a single action to serve the file:
def index(conn, _params) do
redirect conn, to: "/my_app/index.html"
end
added the controller to my routes.ex:
get "/my_app", MyCustomController, :index
None of the above steps worked so far, I only get the Error no route found for GET /my_app/index.html. How could I solve this Issue? I just want to map the URL "/my_app" (or, if nothing else works, "/my_app/index.html") to the path priv/static/my_app/index.html within my phoenix app. Any ideas?
EDIT:
The basic workflow I try to implement is the following:
I have different developers that build some ember.js SPAs in their dedicated folder, located in $phoenix_root/apps/. So I have a developer building $phoenix_root/apps/my_app with ember and ember-cli. This developer uses ember server while developing his app, and has mix phoenix.server running in the background, because the phoenix app itself exposes the required data as an RESTful API.
After each implemented feature, the frontend developer types ember build [...], this task compiles the whole ember.js frontend app into a single folder, with a index.html file and some assets, and moves this folder to $phoenix_root/web/static/assets/my_app. Then phoenix (or, brunch) triggers, and copies this stuff as-is to $phoenix_root/priv/static/my_app, ready to be served like any other asset.
The point is to be able to build a bunch of isolated "frontends" as self-contained packages within a single code base (the phoenix app), while the phoenix app itself has additional (other) stuff to do.
Because the Frontend-Developers auto-generate the SPA everytime, modifying the ever-new index.html file is something I highly want to avoid. Performance-wise it would be the best to just serve these SPAs as the static files they are - they initialize on their own inside the user's browser.
I hope this adds some clarification why I do this.
EDIT 2:
I have a working solution now, see the example repo I created for demonstration purposes: https://github.com/Anonyfox/Phoenix-Example-Multiple-SPA-Frontends
Necessary modifications to the phoenix app:
modify endpoint.ex' Plug.Static to include the SPAs and their assets.
restart mix phoenix.server after this!
Neccessary modifications to the ember.js apps:
add "output-path": "../../web/static/assets/*my_app*/" to .ember-cli, convenience setting to run ember build always with this path
add baseURL: '/*my_app*/' and locationType: 'none' to config/environment.js
rm -rf .git if you want to have all the code versioned within a single project (the purpose of this question)
Your setup should just work. There is only one caveat: every time you change something in lib, you must restart your application.
The only directory that is code reloaded on requests is web. In fact, that's the only difference between lib and web directories. That's why you put long running processes and supervisor in lib, because there is no need to code reload them, and everything else goes in web.
I think easiest way to replace web/templates/layout/app.html.eex with your index html and change assets path inside with <%= static_path(#conn, "/js/app.js") %> helpers to grab your ember app js file from static folder.
Router part:
scope "/", Chat do
pipe_through :browser
get "/", PageController, :index
end
And inside action render conn.
My application is running on Sinatra and deployed on my Apache web server using Passenger. My directory structure is as follows:
approot
` public
` css
- bootstrap.css
` uploads
- empty.txt
` tmp
- restart.txt
` views
- success.haml
- upload.haml
- config.ru
- myapp.rb
Inside upload.haml
%link(rel="stylesheet" href="css/bootstrap.css")
When I run this application on localhost:4567, the CSS loads just fine. However, when I deploy it on my web server, the CSS doesn't load.
On my web server, the application is accessed using: rubyapps.mydomain.com/appname
And if I type: rubyapps.mydomain.com/appname/css/bootstrap.css, I am able to see the contents of my CSS file just fine.
Totally confused, and not getting how Sinatra handles this situation, looking for a little help.
You might be running into the need to use Sinatra's URL helper.
For generating URLs you should use the url helper method, for instance, in Haml:
%a{:href => url('/foo')} foo
It takes reverse proxies and Rack routers into account, if present.
This method is also aliased to to (see below for an example).
Maybe this?
%link(rel="stylesheet" href="../public/css/bootstrap.css")
Or...
%link(rel="stylesheet" href="/css/bootstrap.css")