Skip to content

Commit ec72baf

Browse files
committed
Fix web_app example (didn't compile)
The example depends on the current HEAD and wasn't updated for a while. PromEx increased many dependencies requirements (including phoenix/phoenix_live_view which had breaking changes or deprecations).
1 parent edae7ab commit ec72baf

File tree

15 files changed

+4670
-8234
lines changed

15 files changed

+4670
-8234
lines changed

example_applications/web_app/assets/package-lock.json

Lines changed: 4556 additions & 8126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example_applications/web_app/assets/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,20 @@
2121
"ansi-regex": ">=5.0.1",
2222
"babel-loader": "^8.0.0",
2323
"browserslist": ">=4.16.5",
24-
"copy-webpack-plugin": "^5.1.1",
25-
"css-loader": "^3.4.2",
24+
"copy-webpack-plugin": "^11.0.0",
25+
"css-loader": "^6.8.1",
26+
"css-minimizer-webpack-plugin": "^5.0.1",
2627
"elliptic": "^6.5.7",
27-
"hard-source-webpack-plugin": "^0.13.1",
28+
"glob": "^8.0.0",
2829
"is-svg": "4.4.0",
2930
"lodash": ">=4.17.21",
30-
"mini-css-extract-plugin": "^0.9.0",
31+
"mini-css-extract-plugin": "^2.7.6",
3132
"nanoid": "^3.1.31",
32-
"optimize-css-assets-webpack-plugin": "^5.0.1",
3333
"postcss": ">=8.4.31",
3434
"sass": "^1.22.10",
35-
"sass-loader": "^8.0.2",
35+
"sass-loader": "^13.3.2",
3636
"ssri": ">=6.0.2",
37-
"terser-webpack-plugin": "^2.3.2",
37+
"terser-webpack-plugin": "^5.3.9",
3838
"webpack": "5.94.0",
3939
"webpack-cli": "^5.1.4"
4040
}
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,49 @@
1-
const path = require('path');
2-
const glob = require('glob');
3-
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
4-
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
5-
const TerserPlugin = require('terser-webpack-plugin');
6-
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
7-
const CopyWebpackPlugin = require('copy-webpack-plugin');
1+
const path = require("path");
2+
const glob = require("glob");
3+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
4+
const TerserPlugin = require("terser-webpack-plugin");
5+
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
6+
const CopyWebpackPlugin = require("copy-webpack-plugin");
87

98
module.exports = (env, options) => {
10-
const devMode = options.mode !== 'production';
9+
const devMode = options.mode !== "production";
1110

1211
return {
1312
optimization: {
1413
minimizer: [
15-
new TerserPlugin({ cache: true, parallel: true, sourceMap: devMode }),
16-
new OptimizeCSSAssetsPlugin({})
17-
]
14+
new TerserPlugin({ parallel: true }),
15+
new CssMinimizerPlugin(),
16+
],
1817
},
1918
entry: {
20-
'app': glob.sync('./vendor/**/*.js').concat(['./js/app.js'])
19+
app: glob.sync("./vendor/**/*.js").concat(["./js/app.js"]),
2120
},
2221
output: {
23-
filename: '[name].js',
24-
path: path.resolve(__dirname, '../priv/static/js'),
25-
publicPath: '/js/'
22+
filename: "[name].js",
23+
path: path.resolve(__dirname, "../priv/static/js"),
24+
publicPath: "/js/",
2625
},
27-
devtool: devMode ? 'eval-cheap-module-source-map' : undefined,
26+
devtool: devMode ? "eval-cheap-module-source-map" : undefined,
2827
module: {
2928
rules: [
3029
{
3130
test: /\.js$/,
3231
exclude: /node_modules/,
3332
use: {
34-
loader: 'babel-loader'
35-
}
33+
loader: "babel-loader",
34+
},
3635
},
3736
{
3837
test: /\.[s]?css$/,
39-
use: [
40-
MiniCssExtractPlugin.loader,
41-
'css-loader',
42-
'sass-loader',
43-
],
44-
}
45-
]
38+
use: [MiniCssExtractPlugin.loader, "css-loader", "sass-loader"],
39+
},
40+
],
4641
},
4742
plugins: [
48-
new MiniCssExtractPlugin({ filename: '../css/app.css' }),
49-
new CopyWebpackPlugin([{ from: 'static/', to: '../' }])
50-
]
51-
.concat(devMode ? [new HardSourceWebpackPlugin()] : [])
52-
}
43+
new MiniCssExtractPlugin({ filename: "../css/app.css" }),
44+
new CopyWebpackPlugin({
45+
patterns: [{ from: "static/", to: "../" }],
46+
}),
47+
],
48+
};
5349
};

example_applications/web_app/config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# is restricted to this project.
66

77
# General application configuration
8-
use Mix.Config
8+
import Config
99

1010
config :web_app,
1111
ecto_repos: [WebApp.Repo, WebApp.Repo2],

example_applications/web_app/config/dev.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# Configure your database
44
config :web_app, WebApp.Repo,

example_applications/web_app/config/prod.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# For production, don't forget to configure the url host
44
# to something meaningful, Phoenix uses this information

example_applications/web_app/config/test.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# Configure your database
44
#

example_applications/web_app/lib/web_app/temp_tracker.ex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ defmodule WebApp.TempTracker do
99

1010
def get_coldest_city do
1111
Agent.get(__MODULE__, fn {city, country, temp} ->
12-
"The coldest city on earth is currently #{city}, #{country} with a temperature of #{
13-
kelvin_to_c(temp)
14-
}°C"
12+
"The coldest city on earth is currently #{city}, #{country} with a temperature of #{kelvin_to_c(temp)}°C"
1513
end)
1614
end
1715

example_applications/web_app/lib/web_app_web.ex

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ defmodule WebAppWeb do
2222
use Phoenix.Controller, namespace: WebAppWeb
2323

2424
import Plug.Conn
25-
import WebAppWeb.Gettext
25+
use Gettext, backend: WebAppWeb.Gettext
2626
alias WebAppWeb.Router.Helpers, as: Routes
2727
end
2828
end
@@ -45,7 +45,7 @@ defmodule WebAppWeb do
4545
def live_view do
4646
quote do
4747
use Phoenix.LiveView,
48-
layout: {WebAppWeb.LayoutView, "live.html"}
48+
layout: {WebAppWeb.LayoutView, :live}
4949

5050
unquote(view_helpers())
5151
end
@@ -72,7 +72,7 @@ defmodule WebAppWeb do
7272
def channel do
7373
quote do
7474
use Phoenix.Channel
75-
import WebAppWeb.Gettext
75+
use Gettext, backend: WebAppWeb.Gettext
7676
end
7777
end
7878

@@ -83,12 +83,13 @@ defmodule WebAppWeb do
8383

8484
# Import LiveView helpers (live_render, live_component, live_patch, etc)
8585
import Phoenix.LiveView.Helpers
86+
import Phoenix.Component
8687

8788
# Import basic rendering functionality (render, render_layout, etc)
8889
import Phoenix.View
8990

9091
import WebAppWeb.ErrorHelpers
91-
import WebAppWeb.Gettext
92+
use Gettext, backend: WebAppWeb.Gettext
9293
alias WebAppWeb.Router.Helpers, as: Routes
9394
end
9495
end

example_applications/web_app/lib/web_app_web/gettext.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ defmodule WebAppWeb.Gettext do
2020
2121
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
2222
"""
23-
use Gettext, otp_app: :web_app
23+
use Gettext.Backend, otp_app: :web_app
2424
end

0 commit comments

Comments
 (0)