Upgrade vue-cli to v4, change the way server params injection is made

and serve es6 modules

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-10-17 14:20:22 +02:00
parent 4b80b8616d
commit 6718dd8e69
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
10 changed files with 1314 additions and 840 deletions

2
.gitignore vendored
View file

@ -17,7 +17,7 @@ erl_crash.dump
.env.production .env.production
.env.test .env.test
.env /.env
.env.2 .env.2
setup_db.psql setup_db.psql

View file

@ -1,5 +0,0 @@
{
"presets": [
"@vue/app"
]
}

1
js/.env Normal file
View file

@ -0,0 +1 @@
VUE_APP_INJECT_COMMENT = <meta name="server-injected-data" />

1
js/.gitignore vendored
View file

@ -27,4 +27,3 @@ yarn-error.log*
*.sln *.sln
*.sw* *.sw*
.env

7
js/babel.config.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
presets: [
[
"@vue/app", {useBuiltIns: "entry"}
]
]
};

View file

@ -46,12 +46,13 @@
"@types/leaflet": "^1.5.2", "@types/leaflet": "^1.5.2",
"@types/lodash": "^4.14.141", "@types/lodash": "^4.14.141",
"@types/mocha": "^5.2.6", "@types/mocha": "^5.2.6",
"@vue/cli-plugin-babel": "^3.6.0", "@vue/cli-plugin-babel": "^4.0.3",
"@vue/cli-plugin-e2e-cypress": "^4.0.0-rc.7", "@vue/cli-plugin-e2e-cypress": "^4.0.3",
"@vue/cli-plugin-pwa": "^3.6.0", "@vue/cli-plugin-pwa": "^4.0.3",
"@vue/cli-plugin-typescript": "^3.6.0", "@vue/cli-plugin-router": "^4.0.3",
"@vue/cli-plugin-unit-mocha": "^3.6.0", "@vue/cli-plugin-typescript": "^4.0.3",
"@vue/cli-service": "^3.6.0", "@vue/cli-plugin-unit-mocha": "^4.0.3",
"@vue/cli-service": "^4.0.3",
"@vue/eslint-config-typescript": "^4.0.0", "@vue/eslint-config-typescript": "^4.0.0",
"@vue/test-utils": "^1.0.0-beta.29", "@vue/test-utils": "^1.0.0-beta.29",
"apollo-link-error": "^1.1.12", "apollo-link-error": "^1.1.12",
@ -64,7 +65,7 @@
"tslint": "^5.20.0", "tslint": "^5.20.0",
"tslint-config-airbnb": "^5.11.2", "tslint-config-airbnb": "^5.11.2",
"typescript": "^3.6.3", "typescript": "^3.6.3",
"vue-cli-plugin-styleguidist": "^3.24.2", "vue-cli-plugin-styleguidist": "^3.25.0",
"vue-cli-plugin-webpack-bundle-analyzer": "^1.3.0", "vue-cli-plugin-webpack-bundle-analyzer": "^1.3.0",
"vue-i18n-extract": "^1.0.2", "vue-i18n-extract": "^1.0.2",
"vue-svg-inline-loader": "^1.3.0", "vue-svg-inline-loader": "^1.3.0",

View file

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<!--server-generated-meta--> <%= VUE_APP_INJECT_COMMENT %>
</head> </head>
<body> <body>

View file

@ -1,6 +1,3 @@
const Dotenv = require('dotenv-webpack');
const path = require('path');
module.exports = { module.exports = {
pluginOptions: { pluginOptions: {
webpackBundleAnalyzer: { webpackBundleAnalyzer: {
@ -11,9 +8,6 @@ module.exports = {
runtimeCompiler: true, runtimeCompiler: true,
outputDir: '../priv/static', outputDir: '../priv/static',
configureWebpack: { configureWebpack: {
plugins: [
new Dotenv({ path: path.resolve(process.cwd(), '../.env') }),
],
module: { module: {
rules: [ // fixes https://github.com/graphql/graphql-js/issues/1272 rules: [ // fixes https://github.com/graphql/graphql-js/issues/1272
{ {
@ -28,19 +22,14 @@ module.exports = {
} }
}, },
chainWebpack: config => { chainWebpack: config => {
config // config
.plugin('html') // .plugin('html')
.tap(args => { // .tap(args => {
args[0].minify = { // args[0].minify = {
collapseWhitespace: true, // removeComments: false,
removeComments: false, // };
removeRedundantAttributes: true, // return args
removeScriptTypeAttributes: true, // });
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
};
return args
});
config.module config.module
.rule("vue") .rule("vue")

File diff suppressed because it is too large Load diff

View file

@ -74,7 +74,7 @@ defmodule MobilizonWeb.PageView do
when page in ["actor.html", "event.html", "comment.html"] do when page in ["actor.html", "event.html", "comment.html"] do
with {:ok, index_content} <- File.read(index_file_path()) do with {:ok, index_content} <- File.read(index_file_path()) do
tags = object |> Metadata.build_tags() |> MetadataUtils.stringify_tags() tags = object |> Metadata.build_tags() |> MetadataUtils.stringify_tags()
index_content = String.replace(index_content, "<!--server-generated-meta-->", tags) index_content = String.replace(index_content, "<meta name=server-injected-data>", tags)
{:safe, index_content} {:safe, index_content}
end end
end end
@ -82,7 +82,7 @@ defmodule MobilizonWeb.PageView do
def render("index.html", _assigns) do def render("index.html", _assigns) do
with {:ok, index_content} <- File.read(index_file_path()) do with {:ok, index_content} <- File.read(index_file_path()) do
tags = Instance.build_tags() |> MetadataUtils.stringify_tags() tags = Instance.build_tags() |> MetadataUtils.stringify_tags()
index_content = String.replace(index_content, "<!--server-generated-meta-->", tags) index_content = String.replace(index_content, "<meta name=server-injected-data>", tags)
{:safe, index_content} {:safe, index_content}
end end
end end