webpack.config.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. // TODO??
  21. // Defines the external modules which will be stripped out when bundling for
  22. // the main app. These modules are already loaded in the main app environment,
  23. // so we strip them out to prevent conflicts.
  24. // externals: {},
  25. // Define how file types are handled by webpack
  26. module: {
  27. rules: [{
  28. // Ensure eslint is run before compilation with babel
  29. enforce: 'pre',
  30. test: /\.js$/,
  31. // Only compile application files (dependencies are in ES5 already)
  32. exclude: /node_modules/,
  33. loader: 'eslint-loader'
  34. }, {
  35. // Pass application JS files through babel-loader, compiling to ES5
  36. test: /\.js$/,
  37. // Only compile application files (dependencies are in ES5 already)
  38. exclude: /node_modules/,
  39. use: [{
  40. loader: 'babel-loader',
  41. options: {
  42. presets: [
  43. ['env', { modules: false }]
  44. ],
  45. // Configure babel-loader to cache compiled output so that subsequent
  46. // compile runs are much faster
  47. cacheDirectory: true
  48. }
  49. }]
  50. }]
  51. },
  52. // TODO
  53. // plugins: {}
  54. }