You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building the plugin in dev or build mode, any *.svg (or likely other assets) will be duplicated in the dist/ directory - one set with "regular" or plain-text names, and another set with hashed names.
This behavior is because of webpack.config.ts's CopyWebpackPlugin function. I commented out a few of the // Optional lines. Look at the diff of my webpack.config.ts file to see how I fixed the problem:
HOWEVER, whenever you run npx @grafana/create-plugin update it reverts the contents of webpack.config.ts so this is not a great solution in the long run.
FURTHERMORE, commenting out those 2 optional lines isn't enough, because then in npm run build it hashes the names for all svg files, including logo.svg. This is a problem because package.json references the logo in plain text. So, to solve this, I had to add another line in the copy function to cherry-pick the file called img/logo.svg.
What you expected to happen
The dist/ directory should only contain the plain-text file names on npm run dev and hashed file names on npm run build. Neither script should create file duplicates in dist/
This is my build output after making the changes to webpack.config.ts and running npm run build. I manually copy over logo.svg, because I needed that one to be called logo.svg (not the hashed value) because the logo is referenced in package.json
Here is the contents of that same directory after running npm run dev (it nests the files under img/img, and I'm not sure why, but it still works. As you can see, logo.svg exists twice again, because of my cherry-pick):
How to reproduce it (as minimally and precisely as possible)
@6nv thanks for reporting this issue and it can be indeed reproduced, we do not see this as something that we want to fix with a high priority right now as those cases are quite rare and even then it does not really breaks anything.
Which package(s) does this bug affect?
Package versions
What happened?
When building the plugin in
dev
orbuild
mode, any*.svg
(or likely other assets) will be duplicated in thedist/
directory - one set with "regular" or plain-text names, and another set with hashed names.This behavior is because of
webpack.config.ts
'sCopyWebpackPlugin
function. I commented out a few of the// Optional
lines. Look at the diff of mywebpack.config.ts
file to see how I fixed the problem:nicfv/Psychart@v4.0.6...v4.1.0#diff-735a1fddcd9112f2185fca9468f67db2ddb9a24c07186299c005dacefd18e5f5L152
HOWEVER, whenever you run
npx @grafana/create-plugin update
it reverts the contents ofwebpack.config.ts
so this is not a great solution in the long run.FURTHERMORE, commenting out those 2 optional lines isn't enough, because then in
npm run build
it hashes the names for all svg files, includinglogo.svg
. This is a problem becausepackage.json
references the logo in plain text. So, to solve this, I had to add another line in the copy function to cherry-pick the file calledimg/logo.svg
.What you expected to happen
The
dist/
directory should only contain the plain-text file names onnpm run dev
and hashed file names onnpm run build
. Neither script should create file duplicates indist/
This is my build output after making the changes to
webpack.config.ts
and runningnpm run build
. I manually copy over logo.svg, because I needed that one to be calledlogo.svg
(not the hashed value) because the logo is referenced inpackage.json
Here is the contents of that same directory after running
npm run dev
(it nests the files underimg/img
, and I'm not sure why, but it still works. As you can see, logo.svg exists twice again, because of my cherry-pick):How to reproduce it (as minimally and precisely as possible)
src/img/*.svg
npm install
npm run build
dist/
directoryEnvironment
Additional context
No response
The text was updated successfully, but these errors were encountered: