Progressive Web App with Laravel Mix

Progressive Web App with Laravel Mix

Jul 11 2018, 17:05 in Web Development

Story short, here's how your webpack.mix.js should look like:

let mix = require('laravel-mix');

let SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');

    plugins: [
        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/welcome.blade.php'],
            staticFileGlobsIgnorePatterns: [/\.map$/, /mix-manifest\.json$/, /manifest\.json$/, /service-worker\.js$/],
            runtimeCaching: [
                    urlPattern: /^https:\/\/fonts\.googleapis\.com\//,
                    handler: 'cacheFirst'
            importScripts: ['./js/push_message.js']

mix.js('resources/assets/js/app.js', 'public/js')
   .sass('resources/assets/sass/app.scss', 'public/css');


Disable AdBlock on this domain and offer me a cup of coffee :)