webpack.config.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. }
  23. },
  24. {
  25. test: /\.css$/,
  26. loader: CSSExtractor.extract({ use: 'css-loader' })
  27. },
  28. {
  29. test: /\.html$/,
  30. loader: HTMLExtractor.extract({ use: 'html-loader' })
  31. }
  32. ]
  33. },
  34. plugins: [
  35. CSSExtractor,
  36. HTMLExtractor,
  37. new SpritePlugin()
  38. ]
  39. });
  40. module.exports = config;