/** @license Copyright (c) 2018 The Polymer Project Authors. All rights reserved. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt */ const CopyWebpackPlugin = require('copy-webpack-plugin'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const WorkboxWebpackPlugin = require('workbox-webpack-plugin'); var path = require('path'); module.exports = { devServer: { historyApiFallback: true }, mode: 'production', output: { filename: '[name].[chunkhash:8].js' }, module: { rules: [ { test: /\.js$/, use: { loader: 'babel-loader', options: { presets: [ ['@babel/preset-env', {targets: {ie: '11'}}] ], plugins: ['@babel/plugin-syntax-dynamic-import'] } } } ] }, resolve: { alias: { "react-native": "react-native-web" } }, plugins: [ new CopyWebpackPlugin([ { from: 'images', to: 'images' }, { from: 'data', to: 'data' }, { from: 'node_modules/@webcomponents/webcomponentsjs', to: 'node_modules/@webcomponents/webcomponentsjs' }, { from: 'manifest.json', to: 'manifest.json' }, ]), new HtmlWebpackPlugin({ chunksSortMode: 'none', template: 'index.html', }), new WorkboxWebpackPlugin.GenerateSW({ include: ['index.html', 'manifest.json', /\.js$/], exclude: [/\/@webcomponents\/webcomponentsjs\//], navigateFallback: 'index.html', swDest: 'service-worker.js', clientsClaim: true, skipWaiting: true, runtimeCaching: [ { urlPattern: /\/@webcomponents\/webcomponentsjs\//, handler: 'staleWhileRevalidate' }, { urlPattern: /\/data\//, handler: 'staleWhileRevalidate' }, { urlPattern: /\/images\//, handler: 'staleWhileRevalidate' }, ] }) ] };