Carlos, by the way, if you are not in a hurry I can prepare a proof of
concept this weekend. I just can tell it really works because I am using it
in a system in production.

Of course, that's the develop setup, once develop is done in production we
use nginx-uwsgi only, but in that case there's no cors problem as
everything runs in the same server.


The only thing I miss in web2py (waving Massimo ;) ) is having something
like http://pyramid-webpack.readthedocs.io/en/latest/

It would allow us to write in the view  controller/function.html something
like

<link rel="stylesheet"
href="{{=URL('static',webpack('controller/function.css'))}}"/>

<script src="{{=URL('static',webpack('controller/function.js'))}}"></script>


It would fetch the built files using the dist/webpack-manifest.json
automatically instead of having to write them manually. Now if I use js or
css versioning I have to change the routes in the view whenever I execute
webpack

Regards
José L.

2017-11-14 20:37 GMT+01:00 José Luis Redrejo <[email protected]>:

> Hi Carlos
> I would recommend you to use this webpack helper:
> https://github.com/Plortinus/vue-multiple-pages
>
> Doing "vue init Plortinus/vue-multiple-pages new-project" you get the
> structure to work, just add the div for app to the class and import the
> page js per each page.
>
> Also, in webpack.config.babel.js configuration file ,  if you add
>
>
>   devServer: {
>     host: '127.0.0.1',
>     port: 8001,
>     historyApiFallback: false,
>     noInfo: true,
>     proxy: {
>       '/yourapp/api/*': {
>         target: 'http://127.0.0.1:8080',
>         secure: false
>         // changeOrigin: true,
>         // pathRewrite: { '^/api': '' }
>       }
>     },
>   },
>
>
> You can start web2py server, then webpack dev server and it will do
> queries to web2py without any cors problem.
>
> i.e
> http://localhost:8001/api/whatever will automatically be fetched from
> http://localhost:8080/yourapp/api/whatever
>
> That's how I set it up for web2py to be the backend, and webpack dev
> server to run the frontend.
>
>
> Hope it helps
> José L.
>
> 2017-11-14 17:48 GMT+01:00 Carlos A. Armenta Castro <
> [email protected]>:
>
>> I have using Web2Py for too many years for commercial websites and for
>> Intranets in México, I want to say that Web2Py is an AMAZING Framework!!!
>> For my new project I need to use an SPA VueJs + Webpack for the FrontEnd
>> ( http://quasar-framework.org/ ) and a Web2Py as my BackEnd API Server.
>> I'm curious about to integrate his two web frameworks using web2py routes
>> to serve this two apps in the same port but different URL.
>>
>> Example:
>> http://127.0.1.1/welcome/api ---> My Web2py API Controller
>> http://127.0.1.1/welcome       ---> My VueJS APP with webpack  (
>> http://quasar-framework.org/ ) <-- Pointing to index.html in *dist/ *
>> and permit to use all the static files deposited in the same path
>> *dist/**
>>
>> *VueJS + Webpack APP Structure*
>>
>> ├── *dist/ *                     *# Compiled APP (Serve this files as the 
>> static SPA)*
>> │   *└── index.html
>> │   ├── fonts/
>> │   │   └── ...
>> │   ├── static/
>> │   │   └── ...
>> │   ├── js/
>> │   │   └── ...*
>> ├── config/
>> │   ├── index.js                # main project config
>> │   └── ...
>> ├── src/
>> │   ├── main.js                 # app entry file
>> │   ├── App.vue                 # main app component
>> │   ├── components/             # ui components
>> │   │   └── ...
>> │   └── assets/                 # module assets (processed by webpack)
>> │       └── ...
>> ├── static/                     # pure static assets (directly copied)
>> ├── test/
>> ...
>>
>> Actually I am doing this work in my NginX Server but I Will be happy if I 
>> can do the same thing easily using pure web2py!!!!
>>
>> Why using the same port?  Because the CORS issues, this is the best and easy 
>> way to deal with CORS. I know I can use sub-domains in the same port, I know 
>> I can use ALLOW ORIGIN headers in W2P side but that are not options for me 
>> in this case.
>>
>> NginX config working:
>>
>> location / {
>>                 index index.html index.htm;
>>                 root /home/www-data/vue/applications/simott;
>>                 try_files $uri $uri/ /index.html;
>>         }
>>
>>         location /api {
>>             uwsgi_pass      unix:///tmp/web2py.socket;
>>             include         uwsgi_params;
>>             uwsgi_param     UWSGI_SCHEME $scheme;
>>             uwsgi_param     SERVER_SOFTWARE nginx/$nginx_version;
>>
>>        }
>>
>> Any recommendations? Thanks in advance!
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to