How to move js file dynamically to pub/static folder in Magento2
-
13-12-2019 - |
Question
I created custom module with requirejs-config.js and js folder
when ever page loads requirejs-config is dynamically created in pub/static/_requirejs
folder, but my custom JS is not created automatically i need to copy paste manually in my local system
Do magento2 have any command to build pub/static
JS files or manually we need to move into pub\static\frontend\Magento\luma\en_US\MYNAME_MYMODULE\js
i tried below command but not working
bin\magento setup:static-content:deploy
Solution
First, please ensure that you module properly installed.
If you work in developer mode, files materialized by request, so no needs in any command.
bin/magento setup:static-content:deploy
need only for production mode, where assume that filesystem readonly (see: docs). To identify with mode you use, you can run command bin/magento deploy:mode:show
See more details in official documentation
OTHER TIPS
Magento 2 copies the browser resources (JavaScript, CSS) to the pub/static folder automatically without any console commands.
If your files have not been copied, then you did something wrong. Maybe, you placed the files in a wrong location. Use a core module as an example and do carefully the same.