webpack build javascript folder

0

I'm starting with webpack:

My goal is to be able to take an entire folder where I have all my javascript and generate it in a minifiedcado build.js, what I can not find, is how to make the entry of my webpack.conf a folder and not a file, and in the case of being a file, as I write in that file all the other files that must be included.

Until now I was doing this with Koala, I took a file with the files that I had to include and then when compiling I had only one .js file minifycado.

Sure this is possible with webpack but I can not find a way to configure it

My current configuration is as follows:

const path = require('path');
const paths = {
  DIST: path.resolve(__dirname, 'public/frontend/js'),
  JS: path.resolve(__dirname, 'resources/assets/frontend/js'),
};




// Webpack configuration
 module.exports = {
    mode: "development", // "production" | "development" | "none"
    entry: paths.JS, // path donde se ejecuta el inicio de la compilacion, path de entrada
      output: {
        path: paths.DIST,
        filename: 'app.bundle.js'
      },
};

Which ends up throwing me an error by the value of Entry

  

ERROR in Entry module not found: Error: Can not resolve

    
asked by Pablo 20.04.2018 в 17:05
source

1 answer

0

I do not know if it's the most correct way, but I found a way to solve it: In my configuration file I set the entry for app.js

entry: path.join(paths.JS, 'app.js'),

and in app.js I write the require of each file I want to include

require('./test1.js');
require('./test2.js');

with this package all that is set within the file app.js without having to modify the code of all files js

    
answered by 20.04.2018 в 17:51