webpack.config.js 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* eslint-disable import/no-extraneous-dependencies */
  2. const path = require('path');
  3. const merge = require('deepmerge');
  4. const TextExtractPlugin = require('extract-text-webpack-plugin');
  5. const baseConfig = require('../base-webpack.config');
  6. const SpritePlugin = require('../../plugin');
  7. const CSSExtractor = new TextExtractPlugin('[name].css');
  8. const HTMLExtractor = new TextExtractPlugin('[name].html');
  9. const config = merge(baseConfig, {
  10. context: __dirname,
  11. entry: './main',
  12. output: {
  13. path: path.resolve(__dirname, 'build')
  14. },
  15. module: {
  16. rules: [
  17. {
  18. test: /\.svg$/,
  19. loader: 'svg-sprite-loader',
  20. options: {
  21. extract: true,
  22. spriteFilename: 'sprite-[hash:6].svg'
  23. }
  24. },
  25. {
  26. test: /\.css$/,
  27. loader: CSSExtractor.extract({ use: 'css-loader' })
  28. },
  29. {
  30. test: /\.html$/,
  31. loader: HTMLExtractor.extract({ use: 'html-loader' })
  32. }
  33. ]
  34. },
  35. plugins: [
  36. CSSExtractor,
  37. HTMLExtractor,
  38. new SpritePlugin()
  39. ]
  40. });
  41. module.exports = config;