Guest User

Untitled

a guest
Mar 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  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. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  7.  
  8. function resolve (dir) {
  9. return path.join(__dirname, '..', dir)
  10. }
  11.  
  12. const createLintingRule = () => ({
  13. test: /\.(js|vue)$/,
  14. loader: 'eslint-loader',
  15. enforce: 'pre',
  16. include: [resolve('src'), resolve('test')],
  17. options: {
  18. formatter: require('eslint-friendly-formatter'),
  19. emitWarning: !config.dev.showEslintErrorsInOverlay
  20. }
  21. })
  22.  
  23. module.exports = {
  24. context: path.resolve(__dirname, '../'),
  25. entry: {
  26. app: './src/main.js'
  27. },
  28. output: {
  29. path: config.build.assetsRoot,
  30. filename: '[name].js',
  31. publicPath: process.env.NODE_ENV === 'production'
  32. ? config.build.assetsPublicPath
  33. : config.dev.assetsPublicPath
  34. },
  35. resolve: {
  36. extensions: ['.js', '.vue', '.json'],
  37. alias: {
  38. 'vue$': 'vue/dist/vue.esm.js',
  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',
  53. include: [
  54. resolve('src'),
  55. resolve('test'),
  56. resolve('node_modules/webpack-dev-server/client')]
  57. },
  58. {
  59. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  60. loader: 'url-loader',
  61. options: {
  62. limit: 10000,
  63. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  64. }
  65. },
  66. {
  67. test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
  68. loader: 'url-loader',
  69. options: {
  70. limit: 10000,
  71. name: utils.assetsPath('media/[name].[hash:7].[ext]')
  72. }
  73. },
  74. {
  75. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  76. loader: 'url-loader',
  77. options: {
  78. limit: 10000,
  79. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  80. }
  81. },
  82. {
  83. test: /\.scss$/,
  84. exclude: /node_modules/,
  85. loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!sass-loader'),
  86. },
  87. ]
  88. },
  89. node: {
  90. // prevent webpack from injecting useless setImmediate polyfill because Vue
  91. // source contains it (although only uses it if it's native).
  92. setImmediate: false,
  93. // prevent webpack from injecting mocks to Node native modules
  94. // that does not make sense for the client
  95. dgram: 'empty',
  96. fs: 'empty',
  97. net: 'empty',
  98. tls: 'empty',
  99. child_process: 'empty'
  100. }
  101. }
Add Comment
Please, Sign In to add comment