webpack-concat-plugin icon indicating copy to clipboard operation
webpack-concat-plugin copied to clipboard

No entry points

Open JCarlosR opened this issue 6 years ago • 5 comments

Hi. Thank you for create this plugin. I was trying to use webpack just for minify and concat some files.

Now I have the next:

var path = require('path');
const ConcatPlugin = require('webpack-concat-plugin');

module.exports = {
  // src folder is excluded from jekyll’s build process
  // we’re going to put the generated files in the js folder, and jekyll will grab it
  entry: [],
  output: {
    path: path.resolve(__dirname, 'js')
  },
  plugins: [
    new ConcatPlugin({
      uglify: true, // uglify js or set process.env.NODE_ENV = 'production'
      fileName: 'init.js',
      filesToConcat: ['./src/doubletaptogo.js', './src/init.js']
    }),
    new ConcatPlugin({
      uglify: true, // uglify js or set process.env.NODE_ENV = 'production'
      fileName: 'skills-stick.js',
      filesToConcat: ['./src/skills-stick.js']
    })
  ],

  module: {
  loaders: [
    {
      exclude: /(node_modules)/,
      loader: 'babel-loader',
      query: {
        presets: ['es2015']
      }
    }
    ]
  }
};

I want to use the plugin twice. At least for now I don't have files with dependencies, for that reason I have an empty entry. But webpack fails. Do you know how I can avoid that error?

Thank you.

JCarlosR avatar Jul 19 '17 20:07 JCarlosR

Webpack doesn't allow you to not have entry points actually. See https://webpack.js.org/concepts/entry-points/ for configuration information.

If you just want to minify and concat some file, you can use uglify directly. This is what the plugin does at the end of the day: https://github.com/hxlniada/webpack-concat-plugin/blob/master/index.js#L98

You might want to run the files through babel-loader but this plugin doesn't do that - it reads the files directly from the file system instead. If you want to use babel-loader on the files you can't use this plugin for that.

filipesilva avatar Aug 31 '17 14:08 filipesilva

@filipesilva Would the scope of this plugin include being able to run the files through a loader? This is the last piece of the puzzle I need so that I can get rid of gulp.

jmlopez-rod avatar May 02 '18 21:05 jmlopez-rod

@jmlopez-rod I don't think so. If it runs through a loader then it goes into a webpack bundle AFAIK.

filipesilva avatar May 02 '18 21:05 filipesilva

Would you guys be open to allow an option to transform the contents of the file. That is, after the plugin loads the contents of the file from the system it passes it to a function (specified as an option) which would allows us to transform the code.

The function we can put in the option could be something that transpiles the code either using babel or typescript.

jmlopez-rod avatar May 02 '18 22:05 jmlopez-rod

The plugin direction isn't really something I have any input on, mind you. But I'd say that sounds a lot like replicating webpack itself, and is a lot more complicated than it seems.

filipesilva avatar May 02 '18 22:05 filipesilva