webpack.config.base.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict'
  2. const HtmlWebpackPlugin = require('html-webpack-plugin')
  3. const CopyWebpackPlugin = require('copy-webpack-plugin')
  4. const HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
  5. const { VueLoaderPlugin } = require('vue-loader')
  6. // const { GlslLoaderPlugin } = require('webpack-glsl-loader')
  7. const utils = require('./utils')
  8. module.exports = {
  9. resolve: {
  10. extensions: ['.js', '.vue', '.json', '.glsl'],
  11. alias: {
  12. 'assets': utils.resolve('assets'),
  13. 'pages': utils.resolve('src/pages'),
  14. 'static': utils.resolve('static'),
  15. 'components': utils.resolve('src/components'),
  16. 'api': utils.resolve('src/api'),
  17. 'store': utils.resolve('src/store')
  18. }
  19. },
  20. module: {
  21. rules: [
  22. {
  23. test: /\.(js|vue)$/,
  24. use: 'eslint-loader',
  25. enforce: 'pre'
  26. }, {
  27. test: /\.vue$/,
  28. use: 'vue-loader'
  29. }, {
  30. test: /\.glsl$/,
  31. loader: 'webpack-glsl-loader'
  32. }, {
  33. test: /\.js$/,
  34. use: {
  35. loader: 'babel-loader',
  36. }
  37. }, {
  38. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  39. use: {
  40. loader: 'url-loader',
  41. options: {
  42. limit: 10000,
  43. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  44. }
  45. }
  46. }, {
  47. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  48. use: {
  49. loader: 'url-loader',
  50. options: {
  51. limit: 10000,
  52. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  53. }
  54. }
  55. }, {
  56. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  57. use: {
  58. loader: 'url-loader',
  59. options: {
  60. limit: 10000,
  61. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  62. }
  63. }
  64. }
  65. ]
  66. },
  67. plugins: [
  68. new HtmlWebpackPlugin({
  69. filename: 'index.html',
  70. template: 'index.html',
  71. inject: true,
  72. alwaysWriteToDisk: true
  73. }),
  74. new HtmlWebpackHarddiskPlugin(),
  75. new VueLoaderPlugin(),
  76. // new GlslLoaderPlugin(),
  77. new CopyWebpackPlugin([{
  78. from: utils.resolve('static/img'),
  79. to: utils.resolve('dist/static/img'),
  80. toType: 'dir'
  81. }])
  82. ]
  83. }