You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.2 KiB

  1. const path = require('path')
  2. const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
  3. // const _ = require('lodash')
  4. // const SpriteLoaderPlugin = require('svg-sprite-loader/plugin')
  5. module.exports = options => ({
  6. entry: 'client/index.js',
  7. dist: 'assets',
  8. staticFolder: 'client/static',
  9. filename: {
  10. js: 'js/[name].js',
  11. css: 'css/bundle.css',
  12. images: 'images/[name].[ext]',
  13. fonts: 'fonts/[name].[ext]',
  14. chunk: 'js/[name].chunk.js'
  15. },
  16. autoprefixer: {
  17. browsers: [
  18. 'last 6 Chrome major versions',
  19. 'last 6 Firefox major versions',
  20. 'last 4 Safari major versions',
  21. 'last 4 Edge major versions',
  22. 'last 3 iOS major versions',
  23. 'last 3 Android major versions',
  24. 'last 2 ChromeAndroid major versions',
  25. 'Explorer 11'
  26. ]
  27. },
  28. html: false,
  29. hash: false,
  30. sourceMap: false,
  31. extendWebpack (config) {
  32. // Vue - Default SCSS Imports
  33. config.module.rule('vue')
  34. .use('vue-loader')
  35. .tap(opts => {
  36. opts.loaders.scss.push({
  37. loader: 'sass-resources-loader',
  38. options: {
  39. resources: path.join(__dirname, './client/scss/global.scss')
  40. }
  41. })
  42. return opts
  43. })
  44. // SVG Loader
  45. config.module.rule('svg')
  46. .exclude.add(path.join(__dirname, './client/svg')).end()
  47. .use('file-loader')
  48. .tap(opts => {
  49. opts.name = '[name].[ext]'
  50. opts.outputPath = 'svg/'
  51. return opts
  52. })
  53. config.module.rule('svgSymbols')
  54. .include.add(path.join(__dirname, './client/svg')).end()
  55. .use('raw-loader')
  56. .loader('raw-loader')
  57. // config.module.rule('svg').uses.delete('file-loader')
  58. // config.module.rule('svg')
  59. // .use('svg-sprite-loader')
  60. // .loader('svg-sprite-loader', {
  61. // extract: true,
  62. // spriteFilename: 'svg/symbols.svg'
  63. // })
  64. // config.plugin('svg-sprite-loader')
  65. // .use(SpriteLoaderPlugin)
  66. // Vue with Compiler Alias
  67. config.resolve.alias.set('vue$', 'vue/dist/vue.common.js')
  68. // Bundle Analyze
  69. if (options.analyze) {
  70. config.plugin('analyzer').use(BundleAnalyzerPlugin, [{
  71. analyzerMode: 'static'
  72. }])
  73. }
  74. },
  75. webpack (config) {
  76. return config
  77. }
  78. })