enabling vue compat

This commit is contained in:
Giulio Ganci 2022-04-23 16:15:54 +02:00
parent 3cca3ed2b3
commit 3eb781021c
3 changed files with 23 additions and 14 deletions

View File

@ -116,6 +116,7 @@
"electron-store": "^8.0.1", "electron-store": "^8.0.1",
"electron-updater": "^4.6.1", "electron-updater": "^4.6.1",
"electron-window-state": "^5.0.3", "electron-window-state": "^5.0.3",
"encoding": "^0.1.13",
"leaflet": "^1.7.1", "leaflet": "^1.7.1",
"marked": "^4.0.0", "marked": "^4.0.0",
"moment": "^2.29.1", "moment": "^2.29.1",

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
import { createApp } from 'vue';
import { createApp, configureCompat } from 'vue';
import '@mdi/font/css/materialdesignicons.css'; import '@mdi/font/css/materialdesignicons.css';
import 'leaflet/dist/leaflet.css'; import 'leaflet/dist/leaflet.css';
import '@/scss/main.scss'; import '@/scss/main.scss';
@ -9,6 +9,11 @@ import App from '@/App.vue';
import { store } from '@/store'; import { store } from '@/store';
import i18n from '@/i18n'; import i18n from '@/i18n';
// @TODO: remove after migrating from vue2 -> vue3
configureCompat({
MODE: 3
});
i18n.global.locale = store.state.settings.locale; i18n.global.locale = store.state.settings.locale;
const app = createApp(App); const app = createApp(App);

View File

@ -6,42 +6,45 @@ const { VueLoaderPlugin } = require('vue-loader');
const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const ProgressPlugin = require('progress-webpack-plugin'); const ProgressPlugin = require('progress-webpack-plugin');
const { dependencies, devDependencies, version } = require('./package.json'); const { version } = require('./package.json');
const { contributors } = JSON.parse(fs.readFileSync('./.all-contributorsrc', 'utf-8')); const { contributors } = JSON.parse(fs.readFileSync('./.all-contributorsrc', 'utf-8'));
const parsedContributors = contributors.reduce((acc, c) => { const parsedContributors = contributors.reduce((acc, c) => {
acc.push(c.name); acc.push(c.name);
return acc; return acc;
}, []).join(','); }, []).join(',');
const externals = Object.keys(dependencies).concat(Object.keys(devDependencies));
const isDevMode = process.env.NODE_ENV !== 'production'; const isDevMode = process.env.NODE_ENV !== 'production';
const whiteListedModules = ['vue']; const whiteListedModules = ['.bin', 'vue', '@vue'];
const externals = {};
fs.readdirSync('node_modules')
.filter(x => whiteListedModules.indexOf(x) === -1)
.forEach(mod => {
externals[mod] = `commonjs ${mod}`;
});
const config = { const config = {
name: 'renderer', name: 'renderer',
mode: process.env.NODE_ENV, mode: process.env.NODE_ENV,
devtool: isDevMode ? 'eval-source-map' : false, devtool: isDevMode ? 'eval-cheap-module-source-map' : false,
entry: { entry: path.join(__dirname, './src/renderer/index.js'),
renderer: path.join(__dirname, './src/renderer/index.js')
},
target: 'electron-renderer', target: 'electron-renderer',
output: { output: {
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, 'dist'), path: path.resolve(__dirname, 'dist'),
filename: '[name].js', filename: 'renderer.js'
publicPath: ''
}, },
node: { node: {
global: true, global: true,
__dirname: isDevMode, __dirname: isDevMode,
__filename: isDevMode __filename: isDevMode
}, },
externals: externals.filter((d) => !whiteListedModules.includes(d)), externals: externals,
resolve: { resolve: {
alias: { alias: {
// vue$: 'vue/dist/vue.common.js',
'@': path.resolve(__dirname, 'src/renderer'), '@': path.resolve(__dirname, 'src/renderer'),
common: path.resolve(__dirname, 'src/common') common: path.resolve(__dirname, 'src/common'),
// @TODO: remove after migrating from vue2 -> vue3
vue: '@vue/compat'
}, },
extensions: ['', '.js', '.vue', '.json'], extensions: ['', '.js', '.vue', '.json'],
fallback: { fallback: {