webpack.config.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. const path = require('path');
  2. const HtmlWebpackPlugin = require('html-webpack-plugin');
  3. const CleanWebpackPlugin = require('clean-webpack-plugin');
  4. const CopyWebpackPlugin = require('copy-webpack-plugin');
  5. const outputPath = path.resolve(__dirname, 'dist');
  6. module.exports = {
  7. mode: 'development',
  8. entry: {
  9. app: './src/index.js',
  10. },
  11. module: {
  12. rules: [
  13. {
  14. test: /\.yaml$/,
  15. use: [
  16. { loader: 'json-loader' },
  17. { loader: 'yaml-loader' }
  18. ]
  19. },
  20. {
  21. test: /\.css$/,
  22. use: [
  23. { loader: 'style-loader' },
  24. { loader: 'css-loader' },
  25. ]
  26. }
  27. ]
  28. },
  29. plugins: [
  30. new CleanWebpackPlugin([
  31. outputPath
  32. ]),
  33. new CopyWebpackPlugin([
  34. {
  35. // Copy the Swagger OAuth2 redirect file to the project root;
  36. // that file handles the OAuth2 redirect after authenticating the end-user.
  37. from: 'node_modules/swagger-ui/dist/oauth2-redirect.html',
  38. to: './'
  39. }
  40. ]),
  41. new HtmlWebpackPlugin({
  42. template: 'index.html'
  43. })
  44. ],
  45. output: {
  46. filename: '[name].bundle.js',
  47. path: outputPath,
  48. }
  49. };