Merge pull request #572 from andig/feature/webpack

Replace parcel with webpack
This commit is contained in:
andig 2021-01-03 23:38:09 +01:00 • committed by GitHub
commit b9c3a19eb9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 20898 additions and 23801 deletions

View file

@ -1,8 +1,20 @@
{
"start_url": "../#",
"start_url": "../",
"name": "EV Charge Controller",
"short_name": "EV Charge Controller",
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
"display": "standalone",
"icons": [
{
"src": "android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}

View file

@ -19,10 +19,6 @@
<meta name="theme-color" content="#ffffff" />
<title>evcc</title>
<!-- CSS -->
<link href="../node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet" />
<link href="./css/app.css" rel="stylesheet" />
</head>
<body>
<script>
@ -50,6 +46,5 @@
</div>
</div>
</footer>
<script src="js/app.js"></script>
</body>
</html>

View file

@ -1,3 +1,5 @@
import "../css/app.css";
import "bootstrap/dist/css/bootstrap.min.css";
import "popper.js";
import "bootstrap";
import Vue from "vue";

View file

@ -1,49 +1,51 @@
<template>
<div class="collapse" ref="bar">
<div class="row p-3 bg-warning">
<div class="col-12">
Neue Version verfügbar! Installiert: {{ installed }}. Verfügbar: {{ available }}.
<b
class="px-3"
data-toggle="collapse"
data-target="#release-notes"
v-if="releaseNotes"
>
<a href="#" class="text-body">
Release notes
<fa-icon icon="chevron-up" v-if="notesShown"></fa-icon>
<fa-icon icon="chevron-down" v-else></fa-icon>
</a>
</b>
<b class="px-3">
<a
:href="'https://github.com/andig/evcc/releases/tag/' + available"
class="text-body"
<transition name="fade">
<div v-if="active">
<div class="row p-3 bg-warning">
<div class="col-12">
Neue Version verfügbar! Installiert: {{ installed }}. Verfügbar:
{{ available }}.
<b class="px-3" v-if="releaseNotes">
<a href="#" class="text-body" @click="toggleReleaseNotes">
Release notes
<fa-icon
icon="chevron-down"
class="expand-icon"
:class="{ 'expand-icon-rotated': releaseNotesExpanded }"
>
</fa-icon>
</a>
</b>
<b class="px-3">
<a
:href="'https://github.com/andig/evcc/releases/tag/' + available"
class="text-body"
>
Download <fa-icon icon="chevron-down"></fa-icon>
</a>
</b>
<button
type="button"
class="close float-right"
style="margin-top: -2px"
aria-label="Close"
@click="dismiss"
>
Download <fa-icon icon="chevron-down"></fa-icon>
</a>
</b>
<button
type="button"
class="close float-right"
style="margin-top: -2px"
aria-label="Close"
data-toggle="collapse"
data-target="#version-bar"
>
<span aria-hidden="true">&times;</span>
</button>
<span aria-hidden="true">&times;</span>
</button>
</div>
</div>
<transition name="fade">
<div class="row p-3 bg-light" v-if="releaseNotesExpanded">
<div class="col-12" v-html="releaseNotes"></div>
</div>
</transition>
</div>
<div class="row p-3 bg-light collapse" id="release-notes" ref="notes">
<div class="col-12" v-html="releaseNotes"></div>
</div>
</div>
</transition>
</template>
<script>
import "../icons";
import $ from "jquery";
export default {
name: "Version",
@ -54,34 +56,54 @@ export default {
},
data: function () {
return {
notesShown: false,
dismissed: false,
releaseNotesExpanded: false,
};
},
mounted: function () {
$(this.$refs.notes)
.on(
"show.bs.collapse",
function () {
this.notesShown = true;
}.bind(this)
)
.on(
"hide.bs.collapse",
function () {
this.notesShown = false;
}.bind(this)
methods: {
dismiss: function () {
this.dismissed = true;
},
toggleReleaseNotes: function (e) {
e.preventDefault();
this.releaseNotesExpanded = !this.releaseNotesExpanded;
},
},
computed: {
active: function () {
return (
this.installed != "[[.Version]]" && // go template parsed?
this.installed != "0.0.1-alpha" && // make used?
this.available != this.installed &&
this.dismissed === false
);
},
},
watch: {
available: function () {
if (
this.installed != "[[.Version]]" && // go template parsed?
this.installed != "0.0.1-alpha" && // make used?
this.available != this.installed
) {
$(this.$refs.bar).collapse("show");
}
this.dismissed = false;
this.releaseNotesExpanded = false;
},
},
};
</script>
<style scoped>
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.25s ease-in;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
.expand-icon {
transition: transform 0.25s ease-in;
transform: rotate(0);
}
.expand-icon-rotated {
transform: rotate(-180deg);
}
</style>

View file

@ -10,7 +10,7 @@ const routes = [
{ path: "/config", component: Config },
];
module.exports = new VueRouter({
export default new VueRouter({
routes,
linkExactActiveClass: "active", // Bootstrap <nav>
});

View file

@ -33,4 +33,4 @@ const store = {
},
};
module.exports = store;
export default store;

10512
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,25 +3,23 @@
"description": "",
"main": "index.js",
"scripts": {
"dev": "rimraf dist; parcel watch assets/* --public-url /dist/",
"build": "rimraf dist; parcel build assets/* --public-url /dist/",
"dev": "vue-cli-service build --watch --mode=development",
"build": "vue-cli-service build",
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "prettier assets --write && eslint assets/**/*.js assets/**/*.vue --fix",
"storybook": "start-storybook -p 6006 -s assets,node_modules/jquery/dist,node_modules/popper.js/dist,node_modules/bootstrap/dist",
"build-storybook": "build-storybook",
"fix-audit": "npm-force-resolutions"
"storybook": "start-storybook -p 6006 -s assets,node_modules/bootstrap/dist",
"build-storybook": "build-storybook"
},
"author": "",
"author": "naltatis & andig",
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.12.9",
"@storybook/addon-actions": "^6.1.10",
"@storybook/addon-essentials": "^6.1.10",
"@storybook/addon-links": "^6.1.10",
"@storybook/vue": "^6.1.10",
"@vue/component-compiler-utils": "^3.2.0",
"@vue/cli-service": "^4.5.9",
"@vue/eslint-config-standard": "^5.1.2",
"babel-loader": "^8.2.2",
"eslint": "^7.14.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-import": "^2.22.1",
@ -30,11 +28,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.1.0",
"eslint-plugin-vue": "^7.1.0",
"npm-force-resolutions": "0.0.3",
"parcel-bundler": "^1.12.4",
"prettier": "^2.2.0",
"rimraf": "^3.0.2",
"vue-loader": "^15.9.5",
"vue-template-compiler": "^2.6.12"
},
"engines": {

File diff suppressed because it is too large Load diff

View file

@ -344,7 +344,11 @@ func NewHTTPd(url string, site core.SiteAPI, hub *SocketHub, cache *util.Cache)
if useLocalAssets {
distDir = http.Dir("./dist")
}
static.PathPrefix("/dist/").Handler(http.StripPrefix("/dist/", http.FileServer(distDir)))
for _, public := range []string{"css", "js", "ico"} {
static.PathPrefix(fmt.Sprintf("/%s/", public)).Handler(
http.Handler(http.FileServer(distDir)),
)
}
// api
api := router.PathPrefix("/api").Subrouter()

12
vue.config.js Normal file
View file

@ -0,0 +1,12 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
pages: {
index: { entry: "./assets/js/app.js", template: "./assets/index.html", title: "evcc" },
},
outputDir: "./dist",
publicPath: "./",
configureWebpack: {
plugins: [new CopyWebpackPlugin([{ from: "assets/ico/", to: "ico" }])],
},
};