Build: Fix failing CSS asset paths (#95380)

* build(webpack): set publicpath and process urls to resolve assets correctly

* build(webpack): add back --progress to build

* Add local cdn

(cherry picked from commit 7a19523fa4)

* chore(devenv): fix local_cdn path in ngnix conf

* chore(codeowners): add frontend-ops as owners of local_cdn docker block

---------

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
This commit is contained in:
Jack Westbrook 2024-10-25 13:45:44 +02:00 committed by GitHub
parent d0e124e2f9
commit e894b19c1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 45 additions and 4 deletions

1
.github/CODEOWNERS vendored
View File

@ -241,6 +241,7 @@
/devenv/docker/loadtest/ @grafana/grafana-backend-services-squad
/devenv/docker/rpmtest/ @grafana/grafana-backend-services-squad
/devenv/jsonnet/ @grafana/dataviz-squad
/devenv/local_cdn/ @grafana/frontend-ops
/devenv/local-npm/ @grafana/frontend-ops
/devenv/setup.sh @grafana/grafana-backend-services-squad
/devenv/plugins.yaml @grafana/plugins-platform-frontend

View File

@ -0,0 +1,24 @@
server {
root /data;
autoindex on;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Allow-Headers' '*' always;
add_header 'Access-Control-Allow-Methods' '*';
# add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
add_header 'Access-Control-Allow-Origin' '$http_origin' always;
add_header 'Access-Control-Allow-Methods' '*' always;
add_header 'Access-Control-Allow-Headers' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
rewrite ^/grafana-oss/11.4.0-pre/public(.*)$ $1 last;
}
}

View File

@ -0,0 +1,11 @@
version: '2'
services:
grafana_local_cdn:
image: nginx:alpine
container_name: grafana_local_cdn
ports:
- "8080:80"
volumes:
- ../../public:/data
- ./default.conf:/etc/nginx/conf.d/default.conf

View File

@ -6,7 +6,7 @@
"version": "11.4.0-pre",
"repository": "github:grafana/grafana",
"scripts": {
"build": "NODE_ENV=production nx exec --verbose -- webpack --config scripts/webpack/webpack.prod.js",
"build": "NODE_ENV=production nx exec --verbose -- webpack --config scripts/webpack/webpack.prod.js --progress",
"build:nominify": "yarn run build -- --env noMinify=1",
"dev": "NODE_ENV=dev nx exec -- webpack --config scripts/webpack/webpack.dev.js",
"e2e": "./e2e/start-and-run-suite",

View File

@ -7,7 +7,12 @@ module.exports = function (options) {
return {
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: './',
},
},
{
loader: 'css-loader',
options: {

View File

@ -74,7 +74,7 @@ module.exports = (env = {}) => {
},
require('./sass.rule.js')({
sourceMap: false,
preserveUrl: false,
preserveUrl: true,
}),
],
},

View File

@ -47,7 +47,7 @@ module.exports = (env = {}) =>
},
require('./sass.rule.js')({
sourceMap: false,
preserveUrl: false,
preserveUrl: true,
}),
],
},