保盛仓库管理前台
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.

webpack.base.conf.js 2.1KB

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. module.exports = {
  10. context: path.resolve(__dirname, '../'),
  11. entry: {
  12. app: './src/main.js'
  13. },
  14. output: {
  15. path: config.build.assetsRoot,
  16. filename: '[name].js',
  17. publicPath: process.env.NODE_ENV === 'production'
  18. ? config.build.assetsPublicPath
  19. : config.dev.assetsPublicPath
  20. },
  21. resolve: {
  22. extensions: ['.js', '.vue', '.json'],
  23. alias: {
  24. '@': resolve('src'),
  25. }
  26. },
  27. module: {
  28. rules: [
  29. { //手动添加这一条,相当于是编译识别sass!
  30. test: /\.scss$/,
  31. loaders: ["style", "css", "sass"]
  32. },
  33. {
  34. test: /\.vue$/,
  35. loader: 'vue-loader',
  36. options: vueLoaderConfig
  37. },
  38. {
  39. test: /\.js$/,
  40. loader: 'babel-loader',
  41. include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
  42. },
  43. {
  44. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  45. loader: 'url-loader',
  46. options: {
  47. limit: 10000,
  48. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  49. }
  50. },
  51. {
  52. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  53. loader: 'url-loader',
  54. options: {
  55. limit: 10000,
  56. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  57. }
  58. },
  59. {
  60. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  61. loader: 'url-loader',
  62. options: {
  63. limit: 10000,
  64. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  65. }
  66. }
  67. ]
  68. },
  69. node: {
  70. // prevent webpack from injecting useless setImmediate polyfill because Vue
  71. // source contains it (although only uses it if it's native).
  72. setImmediate: false,
  73. // prevent webpack from injecting mocks to Node native modules
  74. // that does not make sense for the client
  75. dgram: 'empty',
  76. fs: 'empty',
  77. net: 'empty',
  78. tls: 'empty',
  79. child_process: 'empty'
  80. }
  81. }