shared.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  2. const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
  3. const WebpackBar = require('webpackbar');
  4. const paths = require('../utils/paths');
  5. module.exports = env => ({
  6. mode: env.mode,
  7. context: paths.SRC_DIR,
  8. entry: './index.js',
  9. output: {
  10. path: paths.BUILD_DIR,
  11. },
  12. module: {
  13. rules: [
  14. {
  15. test: /\.js$/,
  16. include: paths.SRC_DIR,
  17. use: ['babel-loader'],
  18. },
  19. {
  20. test: /\.(gif|png|jpe?g|svg)$/i,
  21. use: [
  22. {
  23. loader: 'url-loader',
  24. options: {
  25. name: '[path][name].[ext]',
  26. limit: 8192,
  27. esModule: false,
  28. },
  29. },
  30. 'img-loader',
  31. ],
  32. },
  33. {
  34. test: /\.woff(2)?(\?[a-z0-9#=&.]+)?$/,
  35. use: [
  36. {
  37. loader: 'url-loader',
  38. options: {
  39. name: '[name].[ext]',
  40. outputPath: 'fonts/',
  41. limit: 10000,
  42. mimetype: 'application/font-woff',
  43. },
  44. },
  45. ],
  46. },
  47. {
  48. test: /\.(ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
  49. use: [
  50. {
  51. loader: 'file-loader',
  52. options: {
  53. name: '[name].[ext]',
  54. outputPath: 'fonts/',
  55. },
  56. },
  57. ],
  58. },
  59. {
  60. test: /\.html$/,
  61. use: 'html-loader',
  62. },
  63. {
  64. test: /\.hbs$/,
  65. use: 'handlebars-loader',
  66. },
  67. ],
  68. },
  69. plugins: [
  70. new CleanWebpackPlugin(),
  71. new FriendlyErrorsWebpackPlugin(),
  72. new WebpackBar(),
  73. ],
  74. });