Blame view

build/webpack.base.config.js 4.48 KB
c9c5e751   huixisheng   [change] optimize...
1
2
3
  /**
   * 公共配置
   */
4a7f28fd   Sergio Crisostomo   eslint and replac...
4
5
  const path = require('path');
  const webpack = require('webpack');
71eb889f   Graham Fairweather   Enable creation o...
6
  const pkg = require('../package.json');
d962c7fa   Sergio Crisostomo   use version from ...
7
  
9b6ff1ce   huixisheng   add test and upda...
8
  function resolve (dir) {
0a0971da   huixisheng   use gzip
9
      return path.join(__dirname, '..', dir);
9b6ff1ce   huixisheng   add test and upda...
10
  }
c9c5e751   huixisheng   [change] optimize...
11
12
13
14
15
16
17
18
19
20
21
22
  
  module.exports = {
      // 加载器
      module: {
          // https://doc.webpack-china.org/guides/migrating/#module-loaders-module-rules
          rules: [
              {
                  // https://vue-loader.vuejs.org/en/configurations/extract-css.html
                  test: /\.vue$/,
                  loader: 'vue-loader',
                  options: {
                      loaders: {
71eb889f   Graham Fairweather   Enable creation o...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
                          css: [
                              'vue-style-loader',
                              {
                                  loader: 'css-loader',
                                  options: {
                                      sourceMap: true,
                                  },
                              },
                          ],
                          less: [
                              'vue-style-loader',
                              {
                                  loader: 'css-loader',
                                  options: {
                                      sourceMap: true,
                                  },
                              },
                              {
                                  loader: 'less-loader',
                                  options: {
                                      sourceMap: true,
                                  },
                              },
                          ],
c9c5e751   huixisheng   [change] optimize...
47
48
                      },
                      postLoaders: {
71eb889f   Graham Fairweather   Enable creation o...
49
50
51
                          html: 'babel-loader?sourceMap'
                      },
                      sourceMap: true,
c9c5e751   huixisheng   [change] optimize...
52
53
54
55
                  }
              },
              {
                  test: /\.js$/,
71eb889f   Graham Fairweather   Enable creation o...
56
57
58
59
60
                  loader: 'babel-loader',
                  options: {
                      sourceMap: true,
                  },
                  exclude: /node_modules/,
c9c5e751   huixisheng   [change] optimize...
61
62
63
              },
              {
                  test: /\.css$/,
71eb889f   Graham Fairweather   Enable creation o...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
                  loaders: [
                      {
                          loader: 'style-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: 'css-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: '\'autoprefixer-loader\'',
                      },
c9c5e751   huixisheng   [change] optimize...
80
81
82
83
                  ]
              },
              {
                  test: /\.less$/,
71eb889f   Graham Fairweather   Enable creation o...
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                  loaders: [
                      {
                          loader: 'style-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: 'css-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: 'less-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
c9c5e751   huixisheng   [change] optimize...
103
104
105
106
                  ]
              },
              {
                  test: /\.scss$/,
71eb889f   Graham Fairweather   Enable creation o...
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
                  loaders: [
                      {
                          loader: 'style-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: 'css-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
                      {
                          loader: 'sass-loader',
                          options: {
                              sourceMap: true,
                          },
                      },
c9c5e751   huixisheng   [change] optimize...
126
127
                  ]
              },
71eb889f   Graham Fairweather   Enable creation o...
128
129
130
131
132
133
134
135
              {
                  test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
                  loader: 'url-loader?limit=8192'
              },
              {
                  test: /\.(html|tpl)$/,
                  loader: 'html-loader'
              }
c9c5e751   huixisheng   [change] optimize...
136
137
138
          ]
      },
      resolve: {
9b6ff1ce   huixisheng   add test and upda...
139
140
          extensions: ['.js', '.vue'],
          alias: {
d1f37f12   梁灏   update
141
              'vue': 'vue/dist/vue.esm.js',
1f9fbacf   Clark Du   add eslint config...
142
              '@': resolve('src')
9b6ff1ce   huixisheng   add test and upda...
143
          }
0a0971da   huixisheng   use gzip
144
145
      },
      plugins: [
d962c7fa   Sergio Crisostomo   use version from ...
146
147
          new webpack.optimize.ModuleConcatenationPlugin(),
          new webpack.DefinePlugin({
71eb889f   Graham Fairweather   Enable creation o...
148
              'process.env.VERSION': `'${pkg.version}'`
d962c7fa   Sergio Crisostomo   use version from ...
149
          }),
0a0971da   huixisheng   use gzip
150
      ]
c9c5e751   huixisheng   [change] optimize...
151
  };