webpack.base.config.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. const webpack = require('webpack');
  2. const path = require('path');
  3. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  4. const env = process.env
  5. module.exports = {
  6. entry: {
  7. main : "./main.js",
  8. vendors: ['jquery', 'rem', 'vue'],
  9. },
  10. output: {
  11. },
  12. resolve: {
  13. extensions: ['.js', '.vue', '.scss'],
  14. alias: {
  15. "vue": 'vue/dist/vue.esm.js',
  16. "rem": path.resolve(__dirname, './depend/rem/rem.js'),
  17. "popup": path.resolve(__dirname, './depend/artDialog/popup.js'),
  18. "dialog-config": path.resolve(__dirname, './depend/artDialog/dialog-config.js'),
  19. "form": path.resolve(__dirname, './depend/form/form.js'),
  20. "md5": path.resolve(__dirname, './depend/md5/md5.js'),
  21. "template": path.resolve(__dirname, './depend/artTemplate/template.js'),
  22. "cookie": path.resolve(__dirname, './depend/cookie/cookie.js'),
  23. "store": path.resolve(__dirname, './depend/store/store.js'),
  24. "jweixin": path.resolve(__dirname, './depend/jweixin/jweixin-1.0.0.js'),
  25. "lib": path.resolve(__dirname, './depend/lib/lib.js'),
  26. "BDY": path.resolve(__dirname, './depend/BDY/BDY.js'),
  27. "lrz": path.resolve(__dirname, './depend/localResizeIMG/lrz.all.bundle.js'),
  28. "nprogress": path.resolve(__dirname, './depend/nprogress/nprogress.js'),
  29. "extSdk": path.resolve(__dirname, './depend/extSdk/extSdk.js'),
  30. "swiper": path.resolve(__dirname, './depend/swiper/swiper-3.4.2.jquery.min.js'),
  31. "lazyload": path.resolve(__dirname, './depend/lazyload/jquery.lazyload.js')
  32. }
  33. },
  34. module: {
  35. rules: [{
  36. test: /\.js$/,
  37. exclude: /(node_modules|bower_components)/,
  38. use: {
  39. loader : 'babel-loader',
  40. options : {
  41. presets : ['es2015']
  42. }
  43. }
  44. },{
  45. test: /\.vue$/,
  46. loader: 'vue-loader',
  47. options: {
  48. loaders: {
  49. css: ExtractTextPlugin.extract({
  50. fallback: "vue-style-loader",
  51. use: "css-loader",
  52. publicPath: './'
  53. }),
  54. scss: ExtractTextPlugin.extract({
  55. fallback: "vue-style-loader",
  56. use: "sass-loader",
  57. publicPath: './'
  58. })
  59. }
  60. }
  61. },{
  62. test: /\.css$/,
  63. use: ExtractTextPlugin.extract({
  64. fallback: "style-loader",
  65. use: "css-loader",
  66. publicPath: './'
  67. })
  68. },{
  69. test: /\.scss$/,
  70. use: ExtractTextPlugin.extract({
  71. fallback: "style-loader",
  72. use: [{
  73. loader: "css-loader",
  74. options: {
  75. minimize: env.npm_lifecycle_event === 'build' ? true : false
  76. }
  77. }, {
  78. loader: "sass-loader"
  79. }],
  80. publicPath: './'
  81. })
  82. },{
  83. test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
  84. use: 'url-loader?limit=50000'
  85. },{
  86. test: /\.(html|tpl)$/,
  87. use: 'html-loader'
  88. },{
  89. test: /\.json$/,
  90. use: 'json-loader'
  91. }]
  92. },
  93. // babel: {
  94. // presets: ['es2015']
  95. // },
  96. plugins: [
  97. new webpack.optimize.ModuleConcatenationPlugin(),
  98. new webpack.HotModuleReplacementPlugin(),
  99. new webpack.LoaderOptionsPlugin({
  100. minimize: true
  101. })
  102. ]
  103. // extraPath: "../"
  104. };