summaryrefslogtreecommitdiffstats
path: root/webpack.js
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-07-13 10:48:25 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2020-07-13 12:23:42 +0200
commit471a8f026b3fa508affcfa57fdf92f6c80c97a8d (patch)
tree197df411cf2e2357012107610d9ca7ddc141a8f5 /webpack.js
parentd2b703347b02ec0e109287f2dc8ac0abbb11ee7f (diff)
Move to webpack vue global config & bump deps
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'webpack.js')
-rw-r--r--webpack.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/webpack.js b/webpack.js
new file mode 100644
index 00000000..3f30a64c
--- /dev/null
+++ b/webpack.js
@@ -0,0 +1,59 @@
+const { merge } = require('webpack-merge')
+const webpackConfig = require('@nextcloud/webpack-vue-config')
+
+const SassGetGridConfig = require('./src/utils/SassGetGridConfig')
+const ModuleReplaceWebpackPlugin = require('module-replace-webpack-plugin');
+
+const config = {
+ module: {
+ rules: [
+ {
+ test: /\.svg$/,
+ // illustrations
+ loader: 'svg-inline-loader',
+ },
+ {
+ test: /\.scss$/,
+ use: [
+ 'vue-style-loader',
+ 'css-loader',
+ 'postcss-loader',
+ {
+ loader: 'sass-loader',
+ options: {
+ sassOptions: {
+ functions: {
+ 'get($keys)': SassGetGridConfig,
+ },
+ },
+ },
+ },
+ ],
+ },
+ {
+ test: /\.js$/,
+ loader: 'babel-loader',
+ exclude: /node_modules(?!(\/|\\)(hot-patcher|webdav|camelcase)(\/|\\))/,
+ },
+ ],
+ },
+ plugins: [
+ // patch webdav/dist/request.js
+ new ModuleReplaceWebpackPlugin({
+ modules: [{
+ test: /request.js/,
+ replace: './src/patchedRequest.js',
+ exclude: [/patchedRequest.js$/],
+ }],
+ }),
+ ],
+}
+
+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