Start update process for Vue 3

This commit is contained in:
Ramon Wenger 2021-12-13 20:54:09 +01:00
parent 92c34ca80d
commit bdb06be67c
17 changed files with 2901 additions and 2715 deletions

View File

@ -43,7 +43,18 @@ module.exports = {
'@': resolve('src'),
styles: resolve('src/styles'),
gql: resolve('src/graphql/gql'),
vue: '@vue/compat',
},
// we probably don't need this anymore
// fallback: {
// // used to be in node: {setImmediate: false,...}
// setImmediate: false,
// dgram: false,
// fs: false,
// net: false,
// tls: false,
// child_process: false,
// },
},
module: {
rules: [
@ -58,6 +69,11 @@ module.exports = {
img: 'src',
image: 'xlink:href',
},
compilerOptions: {
compatConfig: {
MODE: 2,
},
},
},
},
{
@ -112,16 +128,17 @@ module.exports = {
plugins: [
new VueLoaderPlugin(),
],
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty',
},
// node: {
// // prevent webpack from injecting useless setImmediate polyfill because Vue
// // source contains it (although only uses it if it's native).
// setImmediate: false,
// // prevent webpack from injecting mocks to Node native modules
// // that does not make sense for the client
// dgram: 'empty',
// fs: 'empty',
// net: 'empty',
// tls: 'empty',
// child_process: 'empty',
// },
};

View File

@ -1,93 +1,94 @@
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
'use strict';
const utils = require('./utils');
const webpack = require('webpack');
const config = require('../config');
const path = require('path');
const baseWebpackConfig = require('./webpack.base.conf');
const CopyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const portfinder = require('portfinder');
const {merge} = require('webpack-merge');
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const HOST = process.env.HOST;
const PORT = process.env.PORT && Number(process.env.PORT);
const devWebpackConfig = merge(baseWebpackConfig, {
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
mode: 'development',
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
client: {
logging: 'warn',
overlay: config.dev.errorOverlay,
progress: true,
},
historyApiFallback: {
rewrites: [
{ from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html') },
{from: /.*/, to: path.posix.join(config.dev.assetsPublicPath, 'index.html')},
],
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
// publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll,
}
// quiet: true, // necessary for FriendlyErrorsPlugin
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
'process.env': require('../config/dev.env'),
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NamedModulesPlugin(), // HMR shows correct file names in console on update.
new webpack.NoEmitOnErrorsPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
...require('../config/dev.env')
...require('../config/dev.env'),
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
globOptions: {
ignore: ['.*'],
},
},
],
}),
],
});
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.basePort = process.env.PORT || config.dev.port;
portfinder.getPort((err, port) => {
if (err) {
reject(err)
reject(err);
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
process.env.PORT = port;
// add port to devServer config
devWebpackConfig.devServer.port = port
devWebpackConfig.devServer.port = port;
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
}))
// todo: seems to not be maintained anymore, disable for now
// devWebpackConfig.plugins.push(new FriendlyErrorsPlugin({
// compilationSuccessInfo: {
// messages: [`Your application is running here: http://${devWebpackConfig.devServer.host}:${port}`],
// },
// onErrors: config.dev.notifyOnErrors
// ? utils.createNotifierCallback()
// : undefined,
// }));
resolve(devWebpackConfig)
resolve(devWebpackConfig);
}
})
})
});
});

View File

@ -9,12 +9,12 @@ const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
devtool: config.build.productionSourceMap ? config.build.devtool : false,
mode: 'production',
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
@ -25,15 +25,6 @@ const webpackConfig = merge(baseWebpackConfig, {
new webpack.DefinePlugin({
'process.env': env
}),
new UglifyJsPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css'),
@ -70,37 +61,37 @@ const webpackConfig = merge(baseWebpackConfig, {
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
// split vendor js into its own file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks (module) {
// any required modules inside node_modules are extracted to vendor
return (
module.resource &&
/\.js$/.test(module.resource) &&
module.resource.indexOf(
path.join(__dirname, '../node_modules')
) === 0
)
}
}),
// todo: https://gist.github.com/sokra/1522d586b8e5c0f5072d7565c2bee693
// todo: do we need this? probably default is fine
// new webpack.optimize.CommonsChunkPlugin({
// name: 'vendor',
// minChunks (module) {
// // any required modules inside node_modules are extracted to vendor
// return (
// module.resource &&
// /\.js$/.test(module.resource) &&
// module.resource.indexOf(
// path.join(__dirname, '../node_modules')
// ) === 0
// )
// }
// }),
// extract webpack runtime and module manifest to its own file in order to
// prevent vendor hash from being updated whenever app bundle is updated
new webpack.optimize.CommonsChunkPlugin({
name: 'manifest',
minChunks: Infinity
}),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'manifest',
// minChunks: Infinity
// }),
// This instance extracts shared chunks from code splitted chunks and bundles them
// in a separate chunk, similar to the vendor chunk
// see: https://webpack.js.org/plugins/commons-chunk-plugin/#extra-async-commons-chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'vendor-async',
children: true,
minChunks: 3
}),
// new webpack.optimize.CommonsChunkPlugin({
// name: 'app',
// async: 'vendor-async',
// children: true,
// minChunks: 3
// }),
// copy custom static assets
new CopyWebpackPlugin([

View File

@ -1,5 +1,5 @@
'use strict'
const merge = require('webpack-merge')
const {merge} = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {

View File

@ -33,7 +33,8 @@ module.exports = {
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// devtool: 'cheap-module-eval-source-map',
devtool: 'eval-cheap-module-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help

5092
client/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"author": "ramon / chrigu",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"dev": "webpack serve --progress --config build/webpack.dev.conf.js",
"start": ". ../server/.env && npm run dev",
"lint": "eslint --ext .js,.vue src",
"fix-lint": "eslint --ext .js,.vue --fix src",
@ -44,7 +44,7 @@
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"copy-webpack-plugin": "^10.1.0",
"css-loader": "^0.28.0",
"cy2": "^1.2.1",
"dayjs": "^1.10.4",
@ -52,24 +52,24 @@
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-loader": "^4.0.2",
"eslint-plugin-cypress": "^2.11.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.4",
"friendly-errors-webpack-plugin": "^1.6.1",
"graphql": "^0.13.2",
"friendly-errors-webpack-plugin": "^1.7.0",
"graphql": "^16.1.0",
"graphql-tag": "^2.10.1",
"html-webpack-plugin": "^2.30.1",
"html-webpack-plugin": "^5.5.0",
"lodash": "^4.17.10",
"moment": "^2.24.0",
"node-notifier": "^5.1.2",
"node-sass": "^4.13.1",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"optimize-css-assets-webpack-plugin": "^6.0.1",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
@ -80,30 +80,29 @@
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"survey-vue": "^1.8.77",
"uglifyjs-webpack-plugin": "^1.1.1",
"unfetch": "^3.1.1",
"uploadcare-widget": "^3.6.0",
"url-loader": "^1.0.1",
"uuid": "^3.2.1",
"vee-validate": "^2.2.0",
"vue": "^2.5.17",
"vue": "^3.1.5",
"@vue/compat": "^3.1.5",
"vue-analytics": "^5.16.2",
"vue-apollo": "^3.0.0-beta.16",
"vue-loader": "^15.9.6",
"vue-loader": "^16.8.3",
"vue-matomo": "^3.13.4-0",
"vue-router": "^3.0.1",
"vue-scrollto": "^2.11.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.17",
"vue-toast-notification": "^0.4.1",
"vue-vimeo-player": "0.0.6",
"vuejs-logger": "1.5.5",
"vuetify": "^1.1.8",
"vuex": "^3.0.1",
"webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-dev-server": "^2.9.1",
"webpack-merge": "^4.1.0",
"webpack": "^5.65.0",
"webpack-bundle-analyzer": "^4.5.0",
"webpack-dev-server": "^4.6.0",
"webpack-merge": "^5.8.0",
"whatwg-fetch": "^3.0.0"
},
"engines": {
@ -116,6 +115,7 @@
"not ie <= 8"
],
"devDependencies": {
"@vue/compiler-sfc": "^3.1.5",
"@vue/test-utils": "^1.0.0-beta.29",
"babel-bridge": "^1.12.11",
"babel-core": "^7.0.0-bridge.0",
@ -131,6 +131,7 @@
"mock-apollo-client": "^0.7.0",
"ts-loader": "^8.3.0",
"typescript": "^4.4.3",
"vue-jest": "^3.0.4"
"vue-jest": "^3.0.4",
"webpack-cli": "^4.9.1"
}
}

View File

@ -1,6 +1,6 @@
<template>
<modal>
<template slot="header">
<template v-slot:header>
<modal-input
:placeholder="titlePlaceholder"
:value="localContentBlock.title"
@ -66,16 +66,18 @@
/>
</div>
<div slot="footer">
<a
:class="{'button--disabled': disableSave}"
class="button button--primary"
data-cy="modal-save-button"
@click="save">Speichern</a>
<a
class="button"
@click="$emit('hide')">Abbrechen</a>
</div>
<template v-slot:footer>
<div>
<a
:class="{'button--disabled': disableSave}"
class="button button--primary"
data-cy="modal-save-button"
@click="save">Speichern</a>
<a
class="button"
@click="$emit('hide')">Abbrechen</a>
</div>
</template>
</modal>
</template>
@ -100,16 +102,16 @@
'content-block': Object,
'block-type': {
type: String,
default: 'ContentBlock'
default: 'ContentBlock',
},
'show-task-selection': {
type: Boolean,
default: false
default: false,
},
'disable-save': {
type: Boolean,
default: false
}
default: false,
},
},
components: {
@ -124,7 +126,7 @@
AssignmentForm,
TextForm,
TrashIcon,
Checkbox
Checkbox,
},
data() {
@ -134,14 +136,14 @@
title: this.contentBlock.title,
contents: [...this.contentBlock.contents],
id: this.contentBlock.id || undefined,
isAssignment: this.contentBlock.type && this.contentBlock.type.toLowerCase() === 'task'
isAssignment: this.contentBlock.type && this.contentBlock.type.toLowerCase() === 'task',
}),
me: {}
me: {},
};
},
apollo: {
me: meQuery
me: meQuery,
},
computed: {
@ -150,7 +152,7 @@
},
taskSelection() {
return this.showTaskSelection && this.me.permissions.includes('users.can_manage_school_class_content');
}
},
},
methods: {
@ -177,8 +179,8 @@
...content,
value: {
...content.value,
[key]: value
}
[key]: value,
},
});
},
changeLinkUrl(value, index) {
@ -210,7 +212,7 @@
},
addElement(index) {
this.localContentBlock.contents.splice(index + 1, 0, {
hideAssignment: this.blockType !== 'ContentBlock'
hideAssignment: this.blockType !== 'ContentBlock',
});
},
updateTitle(title) {
@ -220,15 +222,15 @@
changeType(index, type, value) {
let el = {
type: type,
value: Object.assign({}, value)
value: Object.assign({}, value),
};
switch (type) {
case 'text_block':
el = {
...el,
value: {
text: ''
}
text: '',
},
};
break;
case 'link_block':
@ -236,32 +238,32 @@
...el,
value: {
text: '',
url: ''
}
url: '',
},
};
break;
case 'video_block':
el = {
...el,
value: {
url: ''
}
url: '',
},
};
break;
case 'document_block':
el = {
...el,
value: Object.assign({
url: ''
}, value)
url: '',
}, value),
};
break;
case 'image_url_block':
el = {
...el,
value: {
url: ''
}
url: '',
},
};
break;
}
@ -282,8 +284,8 @@
},
switchToDocument(index, value) {
this.changeType(index, 'document_block', value);
}
}
},
},
};
</script>

View File

@ -3,24 +3,26 @@
:hide-header="false"
:small="true"
class="snapshot-created">
<div slot="header">
<template v-slot:header>
<h1 class="snapshot-created__heading">Ein neuer Snapshot wurde erstellt</h1>
</div>
</template>
<div class="snapshot-created__content">
<div class="snapshot-created__entry">
<span class="snapshot-created__title">{{ snapshot.title }}</span>
<span class="snapshot-created__meta">{{ created }} - {{ snapshot.creator }}</span>
</div>
</div>
<div slot="footer">
<a
class="button button--primary"
data-cy="show-all-snapshots-button"
@click="toList">Alle Snapshots anzeigen</a>
<a
class="button"
@click="close">Zurück zum Modul</a>
</div>
<template v-slot:footer>
<div>
<a
class="button button--primary"
data-cy="show-all-snapshots-button"
@click="toList">Alle Snapshots anzeigen</a>
<a
class="button"
@click="close">Zurück zum Modul</a>
</div>
</template>
</modal>
</template>
@ -48,7 +50,7 @@
},
created() {
return dateformat(this.snapshot.created);
}
},
},
methods: {

View File

@ -8,15 +8,17 @@
data-cy="bookmark-note"
@input="localNote.text = $event"
/>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="$emit('save', localNote)">Speichern</a>
<a
class="button"
@click="$emit('hide')">Abbrechen</a>
</div>
<template v-slot:footer>
<div>
<a
class="button button--primary"
data-cy="modal-save-button"
@click="$emit('save', localNote)">Speichern</a>
<a
class="button"
@click="$emit('hide')">Abbrechen</a>
</div>
</template>
</modal>
</template>

View File

@ -6,16 +6,18 @@
@input="text = $event"
/>
<div slot="footer">
<a
:class="{'button--disabled': disableSave}"
class="button button--primary"
data-cy="modal-save-button"
@click="save(text)">Speichern</a>
<a
class="button"
@click="hide()">Abbrechen</a>
</div>
<template v-slot:footer>
<div>
<a
:class="{'button--disabled': disableSave}"
class="button button--primary"
data-cy="modal-save-button"
@click="save(text)">Speichern</a>
<a
class="button"
@click="hide()">Abbrechen</a>
</div>
</template>
</modal>
</template>
@ -31,23 +33,23 @@
export default {
components: {
Modal,
ModalInput
ModalInput,
},
data() {
return {
text: '',
saving: false
saving: false,
};
},
computed: {
...mapGetters({
objectiveGroup: 'currentObjectiveGroup'
objectiveGroup: 'currentObjectiveGroup',
}),
disableSave() {
return this.saving;
}
},
},
methods: {
@ -59,9 +61,9 @@
input: {
objective: Object.assign({}, {
objectiveGroup: this.objectiveGroup,
text: entry
})
}
text: entry,
}),
},
},
update: (store, {data: {addObjective: {objective}}}) => {
try {
@ -71,14 +73,14 @@
if (data.objectiveGroup && data.objectiveGroup.objectives) {
data.objectiveGroup.objectives.push({
...objective,
__typename: 'ObjectiveNode'
__typename: 'ObjectiveNode',
});
store.writeQuery({query, variables, data});
}
} catch (e) {
// Query did not exist in the cache, and apollo throws a generic Error. Do nothing
}
}
},
}).then(() => {
this.saving = false;
this.hide();
@ -86,7 +88,7 @@
},
hide() {
this.$store.dispatch('hideModal');
}
}
},
},
};
</script>

View File

@ -1,11 +1,13 @@
<template>
<modal :hide-header="false">
<h2
class="project-entry-modal__heading"
data-cy="modal-title"
slot="header">
Beitrag erfassen
</h2>
<template v-slot:header>
<h2
class="project-entry-modal__heading"
data-cy="modal-title">
Beitrag erfassen
</h2>
</template>
<div class="project-entry-modal">
<div class="project-entry-modal__form-field">
<textarea
@ -20,13 +22,13 @@
icon="document-with-lines-icon"
data-cy="use-template-button"
text="Vorlage nutzen"
@click.native="useTemplate" />
@click.native="useTemplate"/>
<file-upload
:with-text="true"
:document="localProjectEntry.documentUrl"
data-cy="upload-document-button"
@change-document-url="setDocumentUrl" />
@change-document-url="setDocumentUrl"/>
</div>
</div>
</div>

View File

@ -54,15 +54,17 @@
</template>
</li>
</ul>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="confirm">Speichern</a>
<a
class="button"
@click="cancel">Abbrechen</a>
</div>
<template v-slot:footer>
<div>
<a
class="button button--primary"
data-cy="modal-save-button"
@click="confirm">Speichern</a>
<a
class="button"
@click="cancel">Abbrechen</a>
</div>
</template>
</modal>
</template>

View File

@ -2,23 +2,27 @@
<modal
:hide-header="false"
:small="true">
<h4 slot="header">{{ type }} bearbeiten</h4>
<template v-slot:header>
<h4>{{ type }} bearbeiten</h4>
</template>
<modal-input
:value="name"
placeholder="Klassenname"
data-cy="edit-name-input"
@input="$emit('input', $event)"
/>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="$emit('save')">Speichern</a>
<a
class="button"
@click="$emit('cancel')">Abbrechen</a>
</div>
<template v-slot:footer>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="$emit('save')">Speichern</a>
<a
class="button"
@click="$emit('cancel')">Abbrechen</a>
</div>
</template>
</modal>
</template>
@ -30,16 +34,16 @@
props: {
name: {
type: String,
default: ''
default: '',
},
type: {
type: String,
default: ''
}
default: '',
},
},
components: {
Modal,
ModalInput
ModalInput,
},
};

View File

@ -3,10 +3,11 @@
:hide-header="false"
:small="true"
class="change-visibility">
<h1
class="change-visibility__heading"
data-cy="modal-title"
slot="header">Sichtbarkeit anpassen</h1>
<template v-slot:header>
<h1
class="change-visibility__heading"
data-cy="modal-title">Sichtbarkeit anpassen</h1>
</template>
<div class="change-visibility__content">
<radiobutton
:checked="!restricted"
@ -23,15 +24,17 @@
label="Lernende sehen nur die eigenen Beiträge"
@input="restrict(true)"/>
</div>
<div slot="footer">
<a
class="button button--primary"
data-cy="modal-save-button"
@click="confirm">Speichern</a>
<a
class="button"
@click="cancel">Abbrechen</a>
</div>
<template v-slot:footer>
<div>
<a
class="button button--primary"
data-cy="modal-save-button"
@click="confirm">Speichern</a>
<a
class="button"
@click="cancel">Abbrechen</a>
</div>
</template>
</modal>
</template>
@ -48,7 +51,7 @@
data() {
return {
restricted: false
restricted: false,
};
},
@ -65,8 +68,8 @@
},
cancel() {
this.$modal.cancel();
}
}
},
},
};
</script>

View File

@ -17,7 +17,7 @@
:selected-color="localRoom.appearance"
@input="updateColor"
/>
<template slot="footer">
<template v-slot:footer>
<button
type="submit"
data-cy="room-form-save"

View File

@ -14,7 +14,7 @@
},
"types": [
"cypress"
]
],
},
"include": [
"**/*.*"