
What are the Slack Archives?
Itβs a history of our time together in the Slack Community! Thereβs a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you wonβt be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
hello, is somebody know, how to add javascript in spryker backoffice? What is the best way to do it?

hello, is somebody know, how to add javascript in spryker backoffice? What is the best way to do it?
I created new module, now I need to add javascript in table view. Of course, I can write it in twig templates, but it seems there are better way.
I found this article - https://docs.spryker.com/docs/scos/dev/front-end-development/zed/overriding-webpack-js-scss-for-zed-on-project-level.html#webpack - as I understand, I need create new file src/Pyz/Zed/OrderApiLogging/assets/Zed/js/index.entry.js
I did it with content βalert(βtestβ);β - but it does not work after running npm run zed command
Comments
-
Have you configured your environment to look up for js files in the project level?
0 -
of course no ) how to do it?
0 -
OOTB the demo shop uses the build config from the oryx-for-zed to build zed.
zed script in package.json:"zed": "node ./node_modules/@spryker/oryx-for-zed/build",
0 -
we created one for our project, it may look different based on your needs.
it looks roughly like this (removed project specifics):const oryx = require("@spryker/oryx"); const oryxForZed = require("@spryker/oryx-for-zed"); const path = require('path'); const merge = require('webpack-merge'); const mergeWithStrategy = merge.smartStrategy({ plugins: 'prepend' }); const myCustomZedSettings = mergeWithStrategy(oryxForZed.settings, { entry: { dirs: [path.resolve('./src/Pyz/Zed/')] // Path for entry points on project level }, }); const copyAssetsCallback = require('./lib/copy'); oryxForZed.getConfiguration(myCustomZedSettings) .then(configuration => oryx.build(configuration, copyAssetsCallback)) .catch(error => console.error('An error occurred while creating configuration', error));
0 -
after you are done with the build config you have to change your package.json file to use the new build.js file:
"scripts": { ... "zed": "node ./frontend/zed/build", "zed:watch": "node ./frontend/zed/build --dev", "zed:production": "node ./frontend/zed/build --prod" },
0 -
did it. Created frontend/zed/build.js file with content above. Changed package,json. Run npm run zed. But still the same issue. I am expecting to see an alert on my page, but nothing changed. It seems I missed something
0 -
First let's check if your javascript code was built.
If you look for mentions of your code in your project, do you see any in the dir/public/Backoffice/assets/js
?0 -
Thank you! Found it! Thanks a lot!!!!
0 -
Great, if it's there you just need to import it in your twig file
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 79 Spryker News
- 948 Developer Corner
- 806 Spryker Development
- 91 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K π Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 33 Product & Business Questions
- 69 Spryker Safari Questions
- 50 Random