webpack.base.conf.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. 'use strict'
  2. const path = require('path')
  3. const utils = require('./utils')
  4. const config = require('../config')
  5. const { VueLoaderPlugin } = require('vue-loader')
  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: './src/main.js'
  24. },
  25. externals: {
  26. "CKEDITOR": "window.CKEDITOR"
  27. },
  28. output: {
  29. path: config.build.assetsRoot,
  30. filename: '[name].js',
  31. publicPath:
  32. process.env.NODE_ENV === 'production'
  33. ? config.build.assetsPublicPath
  34. : config.dev.assetsPublicPath
  35. },
  36. resolve: {
  37. extensions: ['.js', '.vue', '.json'],
  38. alias: {
  39. '@': resolve('src')
  40. }
  41. },
  42. module: {
  43. rules: [
  44. ...(config.dev.useEslint ? [createLintingRule()] : []),
  45. {
  46. test: /\.vue$/,
  47. loader: 'vue-loader',
  48. options: vueLoaderConfig
  49. },
  50. {
  51. test: /\.js$/,
  52. loader: 'babel-loader?cacheDirectory',
  53. include: [
  54. resolve('src'),
  55. resolve('test'),
  56. resolve('node_modules/webpack-dev-server/client')
  57. ]
  58. },
  59. {
  60. test: /\.svg$/,
  61. loader: 'svg-sprite-loader',
  62. include: [resolve('src/icons')],
  63. options: {
  64. symbolId: 'icon-[name]'
  65. }
  66. },
  67. {
  68. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  69. loader: 'url-loader',
  70. exclude: [resolve('src/icons')],
  71. options: {
  72. limit: 10000,
  73. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  74. }
  75. },
  76. {
  77. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  78. loader: 'url-loader',
  79. options: {
  80. limit: 10000,
  81. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  82. }
  83. },
  84. {
  85. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  86. loader: 'url-loader',
  87. options: {
  88. limit: 10000,
  89. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  90. }
  91. }
  92. ]
  93. },
  94. plugins: [new VueLoaderPlugin()],
  95. node: {
  96. // prevent webpack from injecting useless setImmediate polyfill because Vue
  97. // source contains it (although only uses it if it's native).
  98. setImmediate: false,
  99. // prevent webpack from injecting mocks to Node native modules
  100. // that does not make sense for the client
  101. dgram: 'empty',
  102. fs: 'empty',
  103. net: 'empty',
  104. tls: 'empty',
  105. child_process: 'empty'
  106. }
  107. }