提交 | 用户 | age
|
3ac5f2
|
1 |
'use strict' |
J |
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 |
} |
aeb317
|
67 |
}, |
J |
68 |
{ |
|
69 |
test: /\.sass$/, |
|
70 |
loaders: ['style', 'css', 'sass'] |
3ac5f2
|
71 |
} |
J |
72 |
] |
|
73 |
}, |
|
74 |
node: { |
|
75 |
// prevent webpack from injecting useless setImmediate polyfill because Vue |
|
76 |
// source contains it (although only uses it if it's native). |
|
77 |
setImmediate: false, |
|
78 |
// prevent webpack from injecting mocks to Node native modules |
|
79 |
// that does not make sense for the client |
|
80 |
dgram: 'empty', |
|
81 |
fs: 'empty', |
|
82 |
net: 'empty', |
|
83 |
tls: 'empty', |
|
84 |
child_process: 'empty' |
|
85 |
} |
|
86 |
} |