webpack.base.conf.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. var path = require('path')
  2. var utils = require('./utils')
  3. var config = require('../config')
  4. var vueLoaderConfig = require('./vue-loader.conf')
  5. function resolve(dir) {
  6. return path.join(__dirname, '..', dir)
  7. }
  8. module.exports = {
  9. entry: {
  10. app: ["babel-polyfill","./src/main.js"]
  11. },
  12. output: {
  13. path: config.build.assetsRoot,
  14. filename: '[name].js',
  15. publicPath: process.env.NODE_ENV !== 'development' ? config.build.assetsPublicPath : config.dev.assetsPublicPath
  16. },
  17. resolve: {
  18. extensions: ['.js', '.vue', '.json'],
  19. alias: {
  20. 'vue$': 'vue/dist/vue.esm.js',
  21. '@': resolve('src'),
  22. 'src': path.resolve(__dirname, '../src'),
  23. 'assets': path.resolve(__dirname, '../src/assets'),
  24. 'components': path.resolve(__dirname, '../src/components'),
  25. 'views': path.resolve(__dirname, '../src/views'),
  26. 'styles': path.resolve(__dirname, '../src/styles'),
  27. 'api': path.resolve(__dirname, '../src/api'),
  28. 'utils': path.resolve(__dirname, '../src/utils'),
  29. 'store': path.resolve(__dirname, '../src/store'),
  30. 'router': path.resolve(__dirname, '../src/router'),
  31. 'vendor': path.resolve(__dirname, '../src/vendor'),
  32. 'static': path.resolve(__dirname, '../static')
  33. }
  34. },
  35. externals: {
  36. jquery: 'jQuery'
  37. },
  38. module: {
  39. rules: [
  40. // {
  41. // test: /\.(js|vue)$/,
  42. // loader: 'eslint-loader',
  43. // enforce: "pre",
  44. // include: [resolve('src'), resolve('test')],
  45. // options: {
  46. // formatter: require('eslint-friendly-formatter')
  47. // }
  48. // },
  49. {
  50. test: /\.vue$/,
  51. loader: 'vue-loader',
  52. options: vueLoaderConfig
  53. },
  54. {
  55. test: /\.js$/,
  56. loader: 'babel-loader?cacheDirectory',
  57. include: [resolve('src'), resolve('test')]
  58. },
  59. {
  60. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  61. loader: 'url-loader',
  62. query: {
  63. limit: 10000,
  64. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  65. }
  66. },
  67. {
  68. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  69. loader: 'url-loader',
  70. query: {
  71. limit: 10000,
  72. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  73. }
  74. }
  75. ]
  76. },
  77. //注入全局mixin
  78. // sassResources: path.join(__dirname, '../src/styles/mixin.scss'),
  79. // sassLoader: {
  80. // data: path.join(__dirname, '../src/styles/index.scss')
  81. // },
  82. }