酷炫数据营销平台

webpack.base.conf.js 2.5KB

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