mirror of https://github.com/nextcloud/photos
Bump deps and use npm7
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
0a6791dc89
commit
e7a034d43d
|
@ -1,11 +1,3 @@
|
||||||
module.exports = {
|
const babelConfig = require('@nextcloud/babel-config')
|
||||||
plugins: ['@babel/plugin-syntax-dynamic-import'],
|
|
||||||
presets: [
|
module.exports = babelConfig
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
modules: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
41
package.json
41
package.json
|
@ -22,7 +22,7 @@
|
||||||
"license": "agpl",
|
"license": "agpl",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "NODE_ENV=production webpack --progress --hide-modules --config webpack.js",
|
"build": "NODE_ENV=production webpack --progress --config webpack.js",
|
||||||
"dev": "NODE_ENV=development webpack --progress --config webpack.js",
|
"dev": "NODE_ENV=development webpack --progress --config webpack.js",
|
||||||
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
|
"watch": "NODE_ENV=development webpack --progress --watch --config webpack.js",
|
||||||
"lint": "eslint --ext .js,.vue src",
|
"lint": "eslint --ext .js,.vue src",
|
||||||
|
@ -58,47 +58,22 @@
|
||||||
"extends @nextcloud/browserslist-config"
|
"extends @nextcloud/browserslist-config"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=14.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.14.5",
|
"@nextcloud/babel-config": "^1.0.0-beta.1",
|
||||||
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
||||||
"@babel/preset-env": "^7.14.5",
|
|
||||||
"@nextcloud/browserslist-config": "^2.1.0",
|
"@nextcloud/browserslist-config": "^2.1.0",
|
||||||
"@nextcloud/eslint-config": "^3.0.0",
|
"@nextcloud/eslint-config": "^5.1.0",
|
||||||
"@nextcloud/eslint-plugin": "^2.0.0",
|
"@nextcloud/stylelint-config": "^1.0.0-beta.0",
|
||||||
"@nextcloud/webpack-vue-config": "^2.0.0",
|
"@nextcloud/webpack-vue-config": "^4.0.3",
|
||||||
"@vue/test-utils": "^1.2.0",
|
"@vue/test-utils": "^1.2.0",
|
||||||
"autoprefixer": "^9.8.6",
|
"autoprefixer": "^9.8.6",
|
||||||
"babel-eslint": "^10.1.0",
|
|
||||||
"babel-loader": "^8.2.2",
|
|
||||||
"babel-loader-exclude-node-modules-except": "^1.2.1",
|
"babel-loader-exclude-node-modules-except": "^1.2.1",
|
||||||
"css-loader": "^4.3.0",
|
|
||||||
"eslint": "^7.28.0",
|
|
||||||
"eslint-config-standard": "^16.0.3",
|
|
||||||
"eslint-plugin-import": "^2.23.4",
|
|
||||||
"eslint-plugin-node": "^11.1.0",
|
|
||||||
"eslint-plugin-promise": "^4.3.1",
|
|
||||||
"eslint-plugin-standard": "^4.1.0",
|
|
||||||
"eslint-plugin-vue": "^7.11.0",
|
|
||||||
"eslint-webpack-plugin": "^2.5.4",
|
|
||||||
"module-replace-webpack-plugin": "0.0.12",
|
"module-replace-webpack-plugin": "0.0.12",
|
||||||
"node-sass": "^5.0.0",
|
"node-sass": "^6.0.0",
|
||||||
"node-sass-utils": "^1.1.3",
|
"node-sass-utils": "^1.1.3",
|
||||||
"postcss-loader": "^4.2.0",
|
"postcss-loader": "^6.1.0",
|
||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"sass-loader": "^10.1.1",
|
|
||||||
"style-loader": "^2.0.0",
|
|
||||||
"stylelint": "^13.13.1",
|
|
||||||
"stylelint-config-recommended-scss": "^4.2.0",
|
|
||||||
"stylelint-scss": "^3.19.0",
|
|
||||||
"stylelint-webpack-plugin": "^2.1.1",
|
|
||||||
"url-loader": "^4.1.1",
|
|
||||||
"vue-loader": "^15.9.7",
|
|
||||||
"vue-template-compiler": "^2.6.12",
|
|
||||||
"webpack": "^4.46.0",
|
|
||||||
"webpack-cli": "^3.3.12",
|
|
||||||
"webpack-merge": "^5.8.0",
|
|
||||||
"workbox-webpack-plugin": "^6.1.1"
|
"workbox-webpack-plugin": "^6.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
plugins: [
|
plugins: [
|
||||||
require('autoprefixer')
|
require('autoprefixer'),
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,6 +143,8 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@import '../mixins/GridSizes.scss';
|
||||||
|
|
||||||
.icon-confirm {
|
.icon-confirm {
|
||||||
transform: rotate(180deg)
|
transform: rotate(180deg)
|
||||||
}
|
}
|
||||||
|
@ -168,38 +170,20 @@ export default {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// generate variants based on grid sizes
|
// Specific grid spacing
|
||||||
// TODO: use mixins/GridSizes as soon as node-sass supports it
|
@include grid-sizes using ($marginTop, $marginW) {
|
||||||
// needs node-sass 5.0 (with libsass 3.6)
|
// we space this with 2/3 margin top, 1/3 margin bottom
|
||||||
// https://github.com/sass/node-sass/pull/2312
|
margin-top: ($marginTop - 44px) * 2 / 3;
|
||||||
$previous: 0;
|
|
||||||
@each $size, $config in get('sizes') {
|
|
||||||
$marginTop: map-get($config, 'marginTop');
|
|
||||||
$marginW: map-get($config, 'marginW');
|
|
||||||
|
|
||||||
// if this is the last entry, only use min-width
|
@if $marginW >= 44px {
|
||||||
$rule: '(min-width: #{$previous}px) and (max-width: #{$size}px)';
|
&__back {
|
||||||
@if $size == 'max' {
|
margin: 0 (($marginW - 44px) / 2);
|
||||||
$rule: '(min-width: #{$previous}px)';
|
|
||||||
}
|
|
||||||
|
|
||||||
@media #{$rule} {
|
|
||||||
.photos-navigation {
|
|
||||||
// we space this with 2/3 margin top, 1/3 margin bottom
|
|
||||||
top: ($marginTop - 44px) * 2 / 3;
|
|
||||||
// padding-left: $marginW;
|
|
||||||
@if $marginW >= 44px {
|
|
||||||
&__back {
|
|
||||||
margin: 0 (($marginW - 44px) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
&--root &__title {
|
|
||||||
padding-left: #{$marginW - 44}px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&--root &__title {
|
||||||
|
padding-left: #{$marginW - 44}px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$previous: $size;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -19,23 +19,23 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@use 'sass:map';
|
||||||
|
|
||||||
// needs node-sass 5.0 (with libsass 3.6)
|
|
||||||
// https://github.com/sass/node-sass/pull/2312
|
|
||||||
@mixin grid-sizes() {
|
@mixin grid-sizes() {
|
||||||
$previous: 0;
|
$previous: 0;
|
||||||
|
|
||||||
@each $size, $config in get('sizes') {
|
@each $size, $config in $sizes {
|
||||||
$count: map-get($config, 'count');
|
$count: map-get($config, 'count');
|
||||||
$marginTop: map-get($config, 'marginTop');
|
$marginTop: map-get($config, 'marginTop');
|
||||||
$marginW: map-get($config, 'marginW');
|
$marginW: map-get($config, 'marginW');
|
||||||
|
|
||||||
@if $size == 'max' {
|
@if $size == 'max' {
|
||||||
@media (min-width: #{$previous}px) {
|
@media (min-width: #{$previous}px) {
|
||||||
@content;
|
@content($marginTop, $marginW);
|
||||||
}
|
}
|
||||||
} @else {
|
} @else {
|
||||||
@media (min-width: #{$previous}px) and (max-width: #{$size}px) {
|
@media (min-width: #{$previous}px) and (max-width: #{$size}px) {
|
||||||
@content;
|
@content($marginTop, $marginW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$previous: $size;
|
$previous: $size;
|
||||||
|
|
|
@ -1,84 +0,0 @@
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
|
||||||
*
|
|
||||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
||||||
*
|
|
||||||
* @license GNU AGPL version 3 or any later version
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
const sass = require('node-sass')
|
|
||||||
const sassUtils = require('node-sass-utils')(sass)
|
|
||||||
|
|
||||||
// sass plugin to implement js configs into scss
|
|
||||||
const sassVars = require('../assets/grid-sizes')
|
|
||||||
|
|
||||||
// Allows us to use js variables in sass so we can havea global config
|
|
||||||
// https://github.com/planetflash/sharing_variables_js_sass/
|
|
||||||
const convertStringToSassDimension = function(result) {
|
|
||||||
// Only attempt to convert strings
|
|
||||||
if (typeof result !== 'string') {
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
const cssUnits = [
|
|
||||||
'rem',
|
|
||||||
'em',
|
|
||||||
'vh',
|
|
||||||
'vw',
|
|
||||||
'vmin',
|
|
||||||
'vmax',
|
|
||||||
'ex',
|
|
||||||
'%',
|
|
||||||
'px',
|
|
||||||
'cm',
|
|
||||||
'mm',
|
|
||||||
'in',
|
|
||||||
'pt',
|
|
||||||
'pc',
|
|
||||||
'ch',
|
|
||||||
]
|
|
||||||
const parts = result.match(/[a-zA-Z]+|[0-9]+/g)
|
|
||||||
const value = parts[0]
|
|
||||||
const unit = parts[parts.length - 1]
|
|
||||||
if (cssUnits.indexOf(unit) !== -1) {
|
|
||||||
result = new sassUtils.SassDimension(parseInt(value, 10), unit)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function(keys) {
|
|
||||||
keys = keys.getValue().split('.')
|
|
||||||
let result = sassVars
|
|
||||||
|
|
||||||
for (let i = 0; i < keys.length; i++) {
|
|
||||||
result = result[keys[i]]
|
|
||||||
|
|
||||||
// Convert to SassDimension if dimenssion
|
|
||||||
if (typeof result === 'string') {
|
|
||||||
result = convertStringToSassDimension(result)
|
|
||||||
} else if (typeof result === 'object') {
|
|
||||||
Object.keys(result).forEach(function(key) {
|
|
||||||
const value = result[key]
|
|
||||||
result[key] = convertStringToSassDimension(value)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
result = sassUtils.castToSass(result)
|
|
||||||
return result
|
|
||||||
}
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2018 John Molakvoæ <skjnldsv@protonmail.com>
|
||||||
|
*
|
||||||
|
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// sass plugin to implement js configs into scss
|
||||||
|
// eslint-disable-next-line node/no-extraneous-require
|
||||||
|
const sass = require('sass')
|
||||||
|
const { sizes } = require('../assets/grid-sizes')
|
||||||
|
|
||||||
|
const gridConfigKeys = Object.keys(sizes)
|
||||||
|
const gridConfigMap = new sass.types.Map(gridConfigKeys.length)
|
||||||
|
|
||||||
|
gridConfigKeys.forEach((size, index) => {
|
||||||
|
const config = sizes[size]
|
||||||
|
const configMap = new sass.types.Map(3)
|
||||||
|
|
||||||
|
configMap.setKey(0, new sass.types.String('count'))
|
||||||
|
configMap.setValue(0, new sass.types.Number(config.count))
|
||||||
|
configMap.setKey(1, new sass.types.String('marginTop'))
|
||||||
|
configMap.setValue(1, new sass.types.Number(config.marginTop))
|
||||||
|
configMap.setKey(2, new sass.types.String('marginW'))
|
||||||
|
configMap.setValue(2, new sass.types.Number(config.marginW))
|
||||||
|
|
||||||
|
gridConfigMap.setKey(index, new sass.types.String(size))
|
||||||
|
gridConfigMap.setValue(index, configMap)
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports = `$sizes: ${gridConfigMap};`
|
|
@ -251,20 +251,11 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$previous: 0;
|
@import '../mixins/GridSizes.scss';
|
||||||
@each $size, $config in get('sizes') {
|
|
||||||
$marginTop: map-get($config, 'marginTop');
|
.grid-container {
|
||||||
$marginW: map-get($config, 'marginW');
|
@include grid-sizes using ($marginTop, $marginW) {
|
||||||
// if this is the last entry, only use min-width
|
padding: 0px #{$marginW}px 256px #{$marginW}px;
|
||||||
$rule: '(min-width: #{$previous}px) and (max-width: #{$size}px)';
|
|
||||||
@if $size == 'max' {
|
|
||||||
$rule: '(min-width: #{$previous}px)';
|
|
||||||
}
|
}
|
||||||
@media #{$rule} {
|
|
||||||
.grid-container {
|
|
||||||
padding: #{$marginTop}px #{$marginW}px 256px #{$marginW}px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$previous: $size;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -279,20 +279,11 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$previous: 0;
|
@import '../mixins/GridSizes.scss';
|
||||||
@each $size, $config in get('sizes') {
|
|
||||||
$marginTop: map-get($config, 'marginTop');
|
.grid-container {
|
||||||
$marginW: map-get($config, 'marginW');
|
@include grid-sizes using ($marginTop, $marginW) {
|
||||||
// if this is the last entry, only use min-width
|
padding: 0px #{$marginW}px 256px #{$marginW}px;
|
||||||
$rule: '(min-width: #{$previous}px) and (max-width: #{$size}px)';
|
|
||||||
@if $size == 'max' {
|
|
||||||
$rule: '(min-width: #{$previous}px)';
|
|
||||||
}
|
}
|
||||||
@media #{$rule} {
|
|
||||||
.grid-container {
|
|
||||||
padding: #{$marginTop}px #{$marginW}px 256px #{$marginW}px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$previous: $size;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -295,20 +295,11 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$previous: 0;
|
@import '../mixins/GridSizes.scss';
|
||||||
@each $size, $config in get('sizes') {
|
|
||||||
$marginTop: map-get($config, 'marginTop');
|
.grid-container {
|
||||||
$marginW: map-get($config, 'marginW');
|
@include grid-sizes using ($marginTop, $marginW) {
|
||||||
// if this is the last entry, only use min-width
|
padding: 0px #{$marginW}px 256px #{$marginW}px;
|
||||||
$rule: '(min-width: #{$previous}px) and (max-width: #{$size}px)';
|
|
||||||
@if $size == 'max' {
|
|
||||||
$rule: '(min-width: #{$previous}px)';
|
|
||||||
}
|
}
|
||||||
@media #{$rule} {
|
|
||||||
.grid-container {
|
|
||||||
padding: 0px #{$marginW}px 256px #{$marginW}px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$previous: $size;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,32 +1,3 @@
|
||||||
module.exports = {
|
const babelConfig = require('@nextcloud/stylelint-config')
|
||||||
extends: 'stylelint-config-recommended-scss',
|
|
||||||
rules: {
|
module.exports = babelConfig
|
||||||
indentation: 'tab',
|
|
||||||
'selector-type-no-unknown': null,
|
|
||||||
'number-leading-zero': null,
|
|
||||||
'rule-empty-line-before': [
|
|
||||||
'always',
|
|
||||||
{
|
|
||||||
ignore: ['after-comment', 'inside-block'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'declaration-empty-line-before': [
|
|
||||||
'never',
|
|
||||||
{
|
|
||||||
ignore: ['after-declaration'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
'comment-empty-line-before': null,
|
|
||||||
'selector-type-case': null,
|
|
||||||
'selector-list-comma-newline-after': null,
|
|
||||||
'no-descending-specificity': null,
|
|
||||||
'string-quotes': 'single',
|
|
||||||
'selector-pseudo-element-no-unknown': [
|
|
||||||
true,
|
|
||||||
{
|
|
||||||
ignorePseudoElements: ['v-deep'],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
plugins: ['stylelint-scss'],
|
|
||||||
}
|
|
||||||
|
|
156
webpack.js
156
webpack.js
|
@ -1,103 +1,79 @@
|
||||||
const { merge } = require('webpack-merge')
|
const path = require('path')
|
||||||
|
const webpack = require('webpack')
|
||||||
const webpackConfig = require('@nextcloud/webpack-vue-config')
|
const webpackConfig = require('@nextcloud/webpack-vue-config')
|
||||||
|
const webpackRules = require('@nextcloud/webpack-vue-config/rules')
|
||||||
|
|
||||||
const SassGetGridConfig = require('./src/utils/SassGetGridConfig')
|
const SassGridConfig = require('./src/utils/SassGridConfig')
|
||||||
const ModuleReplaceWebpackPlugin = require('module-replace-webpack-plugin')
|
|
||||||
const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except')
|
const BabelLoaderExcludeNodeModulesExcept = require('babel-loader-exclude-node-modules-except')
|
||||||
|
|
||||||
const WorkboxPlugin = require('workbox-webpack-plugin')
|
const WorkboxPlugin = require('workbox-webpack-plugin')
|
||||||
|
|
||||||
const config = {
|
webpackRules.RULE_JS.exclude = BabelLoaderExcludeNodeModulesExcept([
|
||||||
module: {
|
'@essentials/request-timeout',
|
||||||
rules: [
|
'@nextcloud/event-bus',
|
||||||
{
|
'camelcase',
|
||||||
test: /\.svg$/,
|
'hot-patcher',
|
||||||
// illustrations
|
'semver',
|
||||||
loader: 'raw-loader',
|
'vue-virtual-grid',
|
||||||
},
|
'webdav',
|
||||||
{
|
])
|
||||||
test: /\.scss$/,
|
webpackRules.RULE_SCSS.use = [
|
||||||
use: [
|
'style-loader',
|
||||||
'style-loader',
|
'css-loader',
|
||||||
'css-loader',
|
'postcss-loader',
|
||||||
'postcss-loader',
|
{
|
||||||
{
|
loader: 'sass-loader',
|
||||||
loader: 'sass-loader',
|
options: {
|
||||||
options: {
|
additionalData: SassGridConfig,
|
||||||
sassOptions: {
|
},
|
||||||
functions: {
|
|
||||||
'get($keys)': SassGetGridConfig,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
loader: 'babel-loader',
|
|
||||||
exclude: BabelLoaderExcludeNodeModulesExcept([
|
|
||||||
'@essentials/request-timeout',
|
|
||||||
'@nextcloud/event-bus',
|
|
||||||
'camelcase',
|
|
||||||
'hot-patcher',
|
|
||||||
'semver',
|
|
||||||
'vue-virtual-grid',
|
|
||||||
'webdav',
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
plugins: [
|
]
|
||||||
// patch webdav/dist/request.js
|
|
||||||
new ModuleReplaceWebpackPlugin({
|
|
||||||
modules: [{
|
|
||||||
test: /request.js/,
|
|
||||||
replace: './src/patchedRequest.js',
|
|
||||||
exclude: [/patchedRequest.js$/],
|
|
||||||
}],
|
|
||||||
}),
|
|
||||||
new WorkboxPlugin.GenerateSW({
|
|
||||||
swDest: 'photos-service-worker.js',
|
|
||||||
clientsClaim: true,
|
|
||||||
skipWaiting: true,
|
|
||||||
exclude: [new RegExp('.*')], // don't do precaching
|
|
||||||
inlineWorkboxRuntime: true,
|
|
||||||
sourcemap: false,
|
|
||||||
|
|
||||||
// Define runtime caching rules.
|
webpackConfig.module.rules = Object.values(webpackRules)
|
||||||
runtimeCaching: [{
|
webpackConfig.module.rules.push({
|
||||||
// Match any preview file request
|
test: /\.svg$/,
|
||||||
urlPattern: /^.*\/core\/preview\?fileId=.*/,
|
// illustrations
|
||||||
|
loader: 'raw-loader',
|
||||||
|
})
|
||||||
|
|
||||||
// Apply a strategy.
|
webpackConfig.plugins.push(
|
||||||
handler: 'CacheFirst',
|
// patch webdav/dist/request.js
|
||||||
|
new webpack.NormalModuleReplacementPlugin(
|
||||||
|
/request.js/,
|
||||||
|
function(resource) {
|
||||||
|
if (resource.context.indexOf('webdav/dist') > -1) {
|
||||||
|
resource.request = path.join(__dirname, 'src/patchedRequest.js')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
new WorkboxPlugin.GenerateSW({
|
||||||
|
swDest: 'photos-service-worker.js',
|
||||||
|
clientsClaim: true,
|
||||||
|
skipWaiting: true,
|
||||||
|
exclude: [new RegExp('.*')], // don't do precaching
|
||||||
|
inlineWorkboxRuntime: true,
|
||||||
|
sourcemap: false,
|
||||||
|
|
||||||
options: {
|
// Define runtime caching rules.
|
||||||
// Use a custom cache name.
|
runtimeCaching: [{
|
||||||
cacheName: 'images',
|
// Match any preview file request
|
||||||
|
urlPattern: /^.*\/core\/preview\?fileId=.*/,
|
||||||
|
|
||||||
// Only cache 10000 images.
|
// Apply a strategy.
|
||||||
expiration: {
|
handler: 'CacheFirst',
|
||||||
maxAgeSeconds: 3600 * 24 * 7, // one week
|
|
||||||
maxEntries: 10000,
|
options: {
|
||||||
},
|
// Use a custom cache name.
|
||||||
|
cacheName: 'images',
|
||||||
|
|
||||||
|
// Only cache 10000 images.
|
||||||
|
expiration: {
|
||||||
|
maxAgeSeconds: 3600 * 24 * 7, // one week
|
||||||
|
maxEntries: 10000,
|
||||||
},
|
},
|
||||||
}],
|
},
|
||||||
}),
|
}],
|
||||||
],
|
})
|
||||||
}
|
)
|
||||||
|
|
||||||
// Remove svg from default url-loader
|
module.exports = webpackConfig
|
||||||
const svgRule = webpackConfig.module.rules.find(rule => rule.test && rule.test.toString().indexOf('|svg') !== -1)
|
|
||||||
svgRule.test = new RegExp(svgRule.test.toString().replace('|svg', ''))
|
|
||||||
|
|
||||||
// Merge configs
|
|
||||||
const mergedConfigs = merge(config, webpackConfig)
|
|
||||||
|
|
||||||
// Remove duplicate rules by the `test` key
|
|
||||||
mergedConfigs.module.rules = mergedConfigs.module.rules
|
|
||||||
.filter((v, i, a) => a.findIndex(t => (t.test.toString() === v.test.toString())) === i)
|
|
||||||
|
|
||||||
// Merge rules by replacing existing tests
|
|
||||||
module.exports = mergedConfigs
|
|
||||||
|
|
Loading…
Reference in New Issue