Skip to content

Commit 51faf40

Browse files
committed
Fix broken modals in production build
We need to overwrite postcss.config.js in vue-modal until kouts/vue-modal#48 is merged and released. Current crazy workaround is probably only working on Unix-like machines.
1 parent 20e51d5 commit 51faf40

File tree

4 files changed

+61
-29
lines changed

4 files changed

+61
-29
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
"description": "Focus on the worthwhile content with Kustosz, open source self-hosted web application. This package contains frontend code.",
55
"scripts": {
66
"serve": "vue-cli-service serve",
7-
"build": "vue-cli-service build",
7+
"build": "cp ./vue-modal-postcss.config.js ./node_modules/@kouts/vue-modal/postcss.config.js && vue-cli-service build",
88
"lint": "vue-cli-service lint"
99
},
1010
"dependencies": {
11-
"@kouts/vue-modal": "^3.0.2",
1211
"@fullhuman/postcss-purgecss": "^3.0.0",
12+
"@kouts/vue-modal": "^3.0.2",
1313
"@vueform/multiselect": "^2.2.0",
1414
"axios": "^0.24.0",
1515
"bootstrap-icons-vue": "^0.8.0",
@@ -48,35 +48,27 @@
4848
"ecmaVersion": 2020
4949
},
5050
"rules": {
51-
"vue/multi-word-component-names": ["error", {
52-
"ignores": [
53-
"Collapse",
54-
"Entries",
55-
"Entry",
56-
"Filters",
57-
"Login",
58-
"Maintenance",
59-
"Settings",
60-
"Sidebar",
61-
"Spinner"
62-
]
63-
}]
51+
"vue/multi-word-component-names": [
52+
"error",
53+
{
54+
"ignores": [
55+
"Collapse",
56+
"Entries",
57+
"Entry",
58+
"Filters",
59+
"Login",
60+
"Maintenance",
61+
"Settings",
62+
"Sidebar",
63+
"Spinner"
64+
]
65+
}
66+
]
6467
}
6568
},
6669
"browserslist": [
6770
"> 1%",
6871
"last 2 versions",
6972
"not dead"
70-
],
71-
"vue": {
72-
"publicPath": "./",
73-
"filenameHashing": false,
74-
"css": {
75-
"loaderOptions": {
76-
"scss": {
77-
"additionalData": "@import '~@/scss/variables.scss';"
78-
}
79-
}
80-
}
81-
}
73+
]
8274
}

vue-modal-postcss.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const IN_PRODUCTION = process.env.NODE_ENV === 'production'
2+
3+
module.exports = {
4+
plugins: [
5+
require('autoprefixer'),
6+
IN_PRODUCTION &&
7+
require('@fullhuman/postcss-purgecss')({
8+
content: ['./**/*.html', './src/**/*.vue'],
9+
defaultExtractor(content) {
10+
const contentWithoutStyleBlocks = content.replace(
11+
/<style[^]+?<\/style>/gi,
12+
""
13+
);
14+
return (
15+
contentWithoutStyleBlocks.match(
16+
/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g
17+
) || []
18+
);
19+
},
20+
safelist: [
21+
/-(leave|enter|appear)(|-(to|from|active))$/,
22+
/^(?!(|.*?:)cursor-move).+-move$/,
23+
/^router-link(|-exact)-active$/,
24+
/data-v-.*/,
25+
/^vm(-.*)?$/
26+
]
27+
})
28+
]
29+
}

vue.config.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
publicPath: "./",
3+
filenameHashing: false,
4+
css: {
5+
loaderOptions: {
6+
scss: {
7+
additionalData: "@import '~@/scss/variables.scss';"
8+
}
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)