webpack.base.conf.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const vueLoaderConfig = require('./vue-loader.conf')
  6. function resolve (dir) {
  7. return path.join(__dirname, '..', dir)
  8. }
  9. const packageName = require('../package.json').name;
  10. module.exports = {
  11. context: path.resolve(__dirname, '../'),
  12. entry: {
  13. app: './src/main.js'
  14. },
  15. output: {
  16. library: `sub-report`,
  17. libraryTarget: 'umd',
  18. jsonpFunction: `webpackJsonp_${packageName}`,
  19. path: config.build.assetsRoot,
  20. filename: '[name].js',
  21. publicPath: process.env.NODE_ENV === 'production'
  22. ? config.build.assetsPublicPath
  23. : config.dev.assetsPublicPath
  24. },
  25. resolve: {
  26. extensions: ['.js', '.vue', '.json'],
  27. alias: {
  28. 'vue$': 'vue/dist/vue.esm.js',
  29. '@': resolve('src'),
  30. }
  31. },
  32. module: {
  33. rules: [
  34. {
  35. test: /\.vue$/,
  36. loader: 'vue-loader',
  37. options: vueLoaderConfig
  38. },
  39. {
  40. test: /\.js$/,
  41. loader: 'babel-loader',
  42. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
  43. },
  44. {
  45. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  46. loader: 'url-loader',
  47. options: {
  48. limit: 10000,
  49. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  50. }
  51. },
  52. {
  53. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  54. loader: 'url-loader',
  55. options: {
  56. limit: 10000,
  57. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  58. }
  59. },
  60. {
  61. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  62. loader: 'url-loader',
  63. options: {
  64. limit: 10000,
  65. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  66. }
  67. }
  68. ]
  69. },
  70. node: {
  71. // prevent webpack from injecting useless setImmediate polyfill because Vue
  72. // source contains it (although only uses it if it's native).
  73. setImmediate: false,
  74. // prevent webpack from injecting mocks to Node native modules
  75. // that does not make sense for the client
  76. dgram: 'empty',
  77. fs: 'empty',
  78. net: 'empty',
  79. tls: 'empty',
  80. child_process: 'empty'
  81. }
  82. }