Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Sep 21, 2022
1 parent c0d0160 commit 9ee0778
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/contextHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ function faviconPluginFromConfig(config) {
logo = './app/configurations/images/default/favicon.png';
}

// Newer versions of this plugin don't support `statsFilename` anymore, but
// this file is being used by app/config.js.
// todo: find a different way to implement this
return new FaviconsWebpackPlugin({
// Your source logo
logo,
Expand Down Expand Up @@ -95,6 +98,7 @@ function faviconPluginFromConfig(config) {
}

function getAllFaviconPlugins() {
// return [];
return getAllConfigs().map(faviconPluginFromConfig);
}

Expand Down
2 changes: 2 additions & 0 deletions digitransit-store/scripts/create-new-module
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ $ npm install @digitransit-store/digitransit-store
\`\`\`
`);

// todo: remove this?
writeFileSync(join(folderPath, 'webpack.config.babel.js'), `const path = require('path');
const mode = process.env.ENV;
Expand All @@ -214,6 +215,7 @@ module.exports = {
[
'@babel/preset-env',
{
// todo?
// loose is needed by older Androids < 4.3 and IE10
loose: true,
modules: false,
Expand Down
96 changes: 96 additions & 0 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');

// const OfflinePlugin = require('offline-plugin');

const CompressionPlugin = require('compression-webpack-plugin');

const WebpackAssetsManifest = require('webpack-assets-manifest');
Expand Down Expand Up @@ -32,6 +34,97 @@ const selectedTheme = new RegExp(

const productionPlugins = [
...faviconPlugins,
// todo
// new OfflinePlugin({

// With 'cache-first' all request are sent to consult the cache first and if the cache is empty, request is sent to the network. With 'network-first' all request are sent to the network first and if network request fails consult the cache as a fallback.
// responseStrategy: 'network-first',
// excludes: [
// '**/.*',
// '**/*.map',
// '**/*.txt',
// '../stats.json',
// '../manifest.json',
// '**/*.gz',
// '**/*.br',
// 'js/*_theme.*.js',
// 'js/*_sprite.*.js',
// 'assets/iconstats-*.json',
// 'assets/icons-*/*',
// ],
// caches: {
// main: [':rest:'],
// additional: [],
// optional: [
// '*.png',
// 'css/*.css',
// 'assets/*.svg',
// 'emitter/*.js',
// 'assets/geojson/*.geojson',
// ':externals:',
// ],
// },
// // src for google fonts might change so https://fonts.gstatic.com addresses might require
// // some maintenance in this list to still keep them cached by service worker in the future.
// externals: [
// 'https://prod.hslfi.hsldev.com/fonts/784131/007A16DD5A18D7C65.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/02F09E5BF2B925BD4.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/076040301BB485C9D.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/1346928704B9283E5.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/1CEFF336D57976EB3.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/1DEEABB198BE4D63F.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/22BA455A4091CC19F.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/2566FE490EDCD6F67.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/277846DB00CF3DB06.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/29B67461E5589EE74.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/2D217B7668941A793.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/3253FBE4A5A578F2D.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/52619AB133F6BB86A.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/532E82510FFBBD207.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/534F8B08DDF1CC33C.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/5604F98701832EA61.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/5F469DF892D6FD752.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/6C5FB8083F348CFBB.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/700C98F3EEEA5EA60.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/7FEEF2DCF7989828E.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/80E39C8AEE33E2FB1.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/85C0D47CA441BAC9A.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/86C88F4E5D2372CB2.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/8819A4AEF420691AB.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/8A8537319E1714352.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/8D4A612AC08BB49AA.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/9A41B5190DBEBADE0.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/B037480DAA4A9B18C.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/B378660B7DF3850A2.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/B3B6DD3CB8EB8281F.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/B45A71222EB5CBFF4.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/B6BF52DDCDAE17D49.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/BE27263FF5E4969A1.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/C54DDF82AD3DE0D70.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/C593C722D057C1CB2.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/C704C82D97246BB50.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/D01FA66F6F11C1D46.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/D147F710C34D01D03.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/E8B40404B085B82FD.css',
// 'https://prod.hslfi.hsldev.com/fonts/784131/F694B0ED52086B2B4.css',
// 'https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu7GxKOzY.woff2',
// 'https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxK.woff2',
// 'https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmWUlfChc4EsA.woff2',
// 'https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmWUlfBBc4.woff2',
// 'https://fonts.gstatic.com/s/robotocondensed/v19/ieVl2ZhZI2eCN5jzbjEETS9weq8-19y7DRs5.woff2',
// 'https://fonts.gstatic.com/s/robotocondensed/v19/ieVl2ZhZI2eCN5jzbjEETS9weq8-19K7DQ.woff2',
// 'https://fonts.gstatic.com/s/robotocondensed/v19/ieVi2ZhZI2eCN5jzbjEETS9weq8-32meGCoYb8td.woff2',
// 'https://fonts.gstatic.com/s/robotocondensed/v19/ieVi2ZhZI2eCN5jzbjEETS9weq8-32meGCQYbw.woff2',
// ],
// updateStrategy: 'changed',
// autoUpdate: 1000 * 60 * 5,
// safeToUseOptionalCaches: true,
// ServiceWorker: {
// entry: './app/util/font-sw.js',
// events: true,
// },
// version: '[contenthash]',
// }),
new MiniCssExtractPlugin({
filename: 'css/[name].[contenthash].css',
chunkFilename: 'css/[name].[contenthash].css',
Expand Down Expand Up @@ -88,6 +181,8 @@ module.exports = {
[
'@babel/preset-env',
{
// todo: use https://babeljs.io/docs/en/assumptions ?
// todo: check if this flag is necessary
modules: false,
},
],
Expand Down Expand Up @@ -130,6 +225,7 @@ module.exports = {
],
},
{
// todo: https://webpack.js.org/guides/asset-modules/
test: /\.(eot|png|ttf|woff|svg|jpeg|jpg)$/,
type: 'asset',
},
Expand Down

0 comments on commit 9ee0778

Please sign in to comment.