webpack.config.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const path = require('path')
  2. module.exports = {
  3. // Defines the "entry point(s)" for the application - i.e. the file which
  4. // bootstraps the application
  5. entry: {
  6. richText: './public/es/rich-text.js'
  7. },
  8. // Define where and how the bundle will be output to disk
  9. // Note: webpack-dev-server does not write the bundle to disk, instead it is
  10. // kept in memory for speed
  11. output: {
  12. path: path.join(__dirname, '/public/js/es'),
  13. filename: '[name].js',
  14. // Output as UMD bundle (allows main JS to import with CJS, AMD or global
  15. // style code bundles
  16. libraryTarget: 'umd',
  17. // Name the exported variable from output bundle
  18. library: ['Frontend', '[name]']
  19. },
  20. // Define how file types are handled by webpack
  21. module: {
  22. rules: [{
  23. // Pass application JS files through babel-loader, compiling to ES5
  24. test: /\.js$/,
  25. // Only compile application files (dependencies are in ES5 already)
  26. exclude: /node_modules/,
  27. use: [{
  28. loader: 'babel-loader',
  29. options: {
  30. presets: [
  31. ['env', { modules: false }]
  32. ],
  33. // Configure babel-loader to cache compiled output so that subsequent
  34. // compile runs are much faster
  35. cacheDirectory: true
  36. }
  37. }]
  38. }]
  39. },
  40. // TODO
  41. // plugins: {}
  42. }