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
|
|
|
|
7
|
|
|
function resolve (dir) { |
8
|
|
|
return path.join(__dirname, '..', dir) |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
const createLintingRule = () => ({ |
12
|
|
|
test: /\.(js|vue)$/, |
13
|
|
|
loader: 'eslint-loader', |
14
|
|
|
enforce: 'pre', |
15
|
|
|
include: [resolve('src'), resolve('test')], |
16
|
|
|
options: { |
17
|
|
|
formatter: require('eslint-friendly-formatter'), |
18
|
|
|
emitWarning: !config.dev.showEslintErrorsInOverlay |
19
|
|
|
} |
20
|
|
|
}) |
21
|
|
|
|
22
|
|
|
module.exports = { |
23
|
|
|
context: path.resolve(__dirname, '../'), |
24
|
|
|
entry: { |
25
|
|
|
app: './src/main.js' |
26
|
|
|
}, |
27
|
|
|
output: { |
28
|
|
|
path: config.build.assetsRoot, |
29
|
|
|
filename: '[name].js', |
30
|
|
|
publicPath: process.env.NODE_ENV === 'production' |
31
|
|
|
? config.build.assetsPublicPath |
32
|
|
|
: config.dev.assetsPublicPath |
33
|
|
|
}, |
34
|
|
|
resolve: { |
35
|
|
|
extensions: ['.js', '.vue', '.json'], |
36
|
|
|
alias: { |
37
|
|
|
'vue$': 'vue/dist/vue.esm.js', |
38
|
|
|
'@': resolve('src'), |
39
|
|
|
} |
40
|
|
|
}, |
41
|
|
|
module: { |
42
|
|
|
rules: [ |
43
|
|
|
...(config.dev.useEslint ? [createLintingRule()] : []), |
44
|
|
|
{ |
45
|
|
|
test: /\.vue$/, |
46
|
|
|
loader: 'vue-loader', |
47
|
|
|
options: vueLoaderConfig |
48
|
|
|
}, |
49
|
|
|
{ |
50
|
|
|
test: /\.js$/, |
51
|
|
|
loader: 'babel-loader', |
52
|
|
|
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')] |
53
|
|
|
}, |
54
|
|
|
{ |
55
|
|
|
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, |
56
|
|
|
loader: 'url-loader', |
57
|
|
|
options: { |
58
|
|
|
limit: 10000, |
59
|
|
|
name: utils.assetsPath('img/[name].[hash:7].[ext]') |
60
|
|
|
} |
61
|
|
|
}, |
62
|
|
|
{ |
63
|
|
|
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, |
64
|
|
|
loader: 'url-loader', |
65
|
|
|
options: { |
66
|
|
|
limit: 10000, |
67
|
|
|
name: utils.assetsPath('media/[name].[hash:7].[ext]') |
68
|
|
|
} |
69
|
|
|
}, |
70
|
|
|
{ |
71
|
|
|
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, |
72
|
|
|
loader: 'url-loader', |
73
|
|
|
options: { |
74
|
|
|
limit: 10000, |
75
|
|
|
name: utils.assetsPath('fonts/[name].[hash:7].[ext]') |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
] |
79
|
|
|
}, |
80
|
|
|
node: { |
81
|
|
|
// prevent webpack from injecting useless setImmediate polyfill because Vue |
82
|
|
|
// source contains it (although only uses it if it's native). |
83
|
|
|
setImmediate: false, |
84
|
|
|
// prevent webpack from injecting mocks to Node native modules |
85
|
|
|
// that does not make sense for the client |
86
|
|
|
dgram: 'empty', |
87
|
|
|
fs: 'empty', |
88
|
|
|
net: 'empty', |
89
|
|
|
tls: 'empty', |
90
|
|
|
child_process: 'empty' |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|