lundi 5 mars 2018

configuring SW-precache webpac plugin: can it work with get in the Url?

Right now in our web app, we have a route that goes like this:

Route::get('/{storeName}','HomeController@mainPage');

And using the name of the Store, we load the information of the store, using different templates, depending on the speciality of the store. We have several views, selectin wich one to load in the controller:

  class HomeController extends Controller
    {
       public function mainPage($storeName)
      {
       (..... Calls to the DB and other things........)
       return view('homePage/'.$store->template,[store-data])
      }
   }

We've been considering migrating to a Progressive Web App, and i've been looking into service worker precache. Im wondering how can i do something similar in the dynamicUrlToDependencies.

So far, as i understand it, it works by passing the url, and then the view, this:

module.exports.plugins.push(
    new SWPrecacheWebpackPlugin({
        cacheId: 'pwa',
        filename: 'service-worker.js',
        staticFileGlobs: ['public/**/*.{css,eot,svg,ttf,woff,woff2,js,html}'],
        minify: true,
        stripPrefix: 'public/',
        handleFetch: true,
        dynamicUrlToDependencies: {
            '/': ['resources/views/landing/landing.blade.php'],
            '/planes': ['resources/views/landing/new-precios.blade.php'],
            '/registro': ['resources/views/landing/registro.blade.php'],
            '/politicas-privacidad': ['resources/views/landing/politicas.blade.php'],
            '/articles': ['resources/views/articles.blade.php']
        },
        staticFileGlobsIgnorePatterns: [/\.map$/, /mix-manifest\.json$/, /manifest\.json$/, /service-worker\.js$/],
        runtimeCaching: [
            {
                urlPattern: /^https:\/\/fonts\.googleapis\.com\//,
                handler: 'cacheFirst'
            },
            {
                urlPattern: /^https:\/\/www\.thecocktaildb\.com\/images\/media\/drink\/(\w+)\.jpg/,
                handler: 'cacheFirst'
            }
        ],
        importScripts: ['./js/push_message.js']
    })
);

How can i put something like /{$storeName} in the dynamicToUrlDependencies? can i call a folder of views, like ['resources/views/homePagesTemplates/*.blade.php']? Is it even possible?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2Fe32yh
via IFTTT

Aucun commentaire:

Enregistrer un commentaire