webpack.base.conf.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. var path = require('path')
  2. var config = require('../config')
  3. var utils = require('./utils')
  4. var projectRoot = path.resolve(__dirname, '../')
  5. var env = process.env.NODE_ENV
  6. // check env & config/index.js to decide weither to enable CSS Sourcemaps for the
  7. // various preprocessor loaders added to vue-loader at the end of this file
  8. var cssSourceMapDev = (env === 'development' && config.dev.cssSourceMap)
  9. var cssSourceMapProd = (env === 'production' && config.build.productionSourceMap)
  10. var useCssSourceMap = cssSourceMapDev || cssSourceMapProd
  11. module.exports = {
  12. entry: {
  13. app: './src/main.js'
  14. },
  15. output: {
  16. path: config.build.assetsRoot,
  17. publicPath: process.env.NODE_ENV === 'production' ? config.build.assetsPublicPath : config.dev.assetsPublicPath,
  18. filename: '[name].js'
  19. },
  20. resolve: {
  21. extensions: ['', '.js', '.vue'],
  22. fallback: [path.join(__dirname, '../node_modules')],
  23. alias: {
  24. 'vue$': 'vue/dist/vue.runtime.common',
  25. 'src': path.resolve(__dirname, '../src'),
  26. 'assets': path.resolve(__dirname, '../src/assets'),
  27. 'components': path.resolve(__dirname, '../src/components')
  28. }
  29. },
  30. resolveLoader: {
  31. fallback: [path.join(__dirname, '../node_modules')]
  32. },
  33. module: {
  34. noParse: /node_modules\/localforage\/dist\/localforage.js/,
  35. preLoaders: [
  36. {
  37. test: /\.vue$/,
  38. loader: 'eslint',
  39. include: projectRoot,
  40. exclude: /node_modules/
  41. },
  42. {
  43. test: /\.js$/,
  44. loader: 'eslint',
  45. include: projectRoot,
  46. exclude: /node_modules/
  47. }
  48. ],
  49. loaders: [
  50. {
  51. test: /\.vue$/,
  52. loader: 'vue'
  53. },
  54. {
  55. test: /\.jsx?$/,
  56. loader: 'babel',
  57. include: projectRoot,
  58. exclude: /node_modules\/(?!tributejs)/
  59. },
  60. {
  61. test: /\.json$/,
  62. loader: 'json'
  63. },
  64. {
  65. test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
  66. loader: 'url',
  67. query: {
  68. limit: 10000,
  69. name: utils.assetsPath('img/[name].[hash:7].[ext]')
  70. }
  71. },
  72. {
  73. test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
  74. loader: 'url',
  75. query: {
  76. limit: 10000,
  77. name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
  78. }
  79. }
  80. ]
  81. },
  82. eslint: {
  83. formatter: require('eslint-friendly-formatter')
  84. },
  85. vue: {
  86. loaders: utils.cssLoaders({ sourceMap: useCssSourceMap }),
  87. postcss: [
  88. require('autoprefixer')({
  89. browsers: ['last 2 versions']
  90. })
  91. ]
  92. }
  93. }