Christian Michael
Christian Michael

Reputation: 2316

Shopware 6: Not compiling my main.js in my custom plugin

I added custom javascript in my custom plugin theme. I did exactly what is descriped here:

https://developer.shopware.com/docs/guides/plugins/plugins/storefront/add-custom-javascript

My main.js is in:

custom/plugins/myplugin/src/Resources/app/storefront/src/main.js

I compile my javascript with the command:

./bin/build-storefront.sh

Now I would expect my javascript (in compiled form of course) here:

plublic/theme/mythemehash/js/all.js

But it is not there! The all.js is existing but my javascript is not in there. The creation date of the all.js file is equal to when I compiled my command, so the compiling it self runs, but my main.js is not taken into account.

What can I do?

Shopware 6.4.20.1

.env/ APP_ENV=dev

Upvotes: 1

Views: 1679

Answers (1)

dneustadt
dneustadt

Reputation: 13161

After you run the build script, the compiled assets of your plugin should be located at MyPlugin/src/Resources/app/storefront/dist/storefront/js. If it's there your assets have been successfully compiled. Make sure your plugin is active and installed when you run the script, otherwise your plugin's assets will be ignored. To do so from the CLI you can run these two commands in order:

bin/console plugin:refresh
bin/console plugin:install MyPlugin --activate

In theory you shouldn't have to do anything else But you could still try to manually install the assets and compile the theme. To do so run these two commands from within the shopware root directory, one after the other:

bin/console assets:install
bin/console theme:compile

Upvotes: 2

Related Questions