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