Search code examples
reactjswebpackbabeljswebpack-4babel-loader

How to use Webpack for Just Transpiling not for Bundling


can I just use Webpack to transpile code from Src folder to build folder I don't want to do module bundler just transpiling of code while maintain folder structure in Src Folder

 src
   - component (folder)
   - utils . (folder)
     index.js 

 build
    - component (folder)
    - utils . (folder)
      index.js

Solution

  • I don't know if you can use WebPack, but babel comes with a CLI babel-cli which can transpile your scripts.

    First, install the CLI.

    npm install --save-dev babel-cli
    

    Now you can use babel on the command line to transpile your files. The example is taken from Babel CLI

    This will transpile everything below src/** and put the result into lib/

    babel src --out-dir lib
    

    babel-cli will read your .babelrc file and transpile accordingly. You could even add the --watch flag, which will scan your sources and continuously transpile all files that have changed.