简体   繁体   中英

How to use Babel or webpack in a old php site with separate modules

I have an old project and I cannot use ES6 syntax because I don't know how to implement Babel or Webpack to transpile ES6 to ES5 .

All the js modules are executed in a main.php file like this:

<script language="JavaScript" type="text/javascript"  src="<?php echo $documentroot;?>
        MAIN.js?v=<?php echo $jsVersion;?>">
</script>

How can I configure Babel to work with this old setup? the website uses jQuery. in the Babel setup page it assumes to use npm, but the project do not use node or npm, only pure php and jQuery.

Webpack also requires as prerequisite Node.js in the installation guide

For practical use of Babel/Webpack, you do need the Node/npm stack available in your development environment.

The server actually serving your project does not need them available, if you package and transpile files locally (or in a CI pipeline) and deploy them onto the server, just like they were plain old JS modules.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM