-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathwebpack.config.js
More file actions
109 lines (108 loc) · 2.57 KB
/
webpack.config.js
File metadata and controls
109 lines (108 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
const {
resolve
} = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const url = require('url');
module.exports = (options = {}) => ({
entry: {
vendor: './src/vendor',
app: './src/main.js'
},
output: {
path: resolve(__dirname, 'dist'),
filename: options.dev ? '[name].js' : '[name].[chunkhash:7].js',
chunkFilename: '[id].[chunkhash:7].js',
publicPath: '/'
},
module: {
rules: [{
test: /\.vue$/,
use: [
{
loader: 'vue-loader',
options: {
postcss: require('./postcss.config.js').plugins
}
}
]
},
{
test: /\.js$/,
use: [
{
loader: 'buble-loader',
query: {
objectAssign: 'Object.assign'
}
}
],
exclude: /node_modules/
},
{
test: /\.(js|vue)$/,
exclude: /node_modules/,
enforce: 'pre',
use: ['eslint-loader']
},
{
test: /\.css$/,
loader: options.dev
? 'style-loader!css-loader?sourceMap!postcss-loader?sourceMap'
: ExtractTextPlugin.extract({
fallbackLoader: 'style-loader',
loader: 'css-loader?sourceMap!postcss-loader?sourceMap'
})
},
{
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
use: [{
loader: 'url-loader',
options: {
limit: 10000,
name: 'assets/[name].[hash:7].[ext]'
}
}]
}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
new HtmlWebpackPlugin({
template: 'index.tpl'
}),
new CopyWebpackPlugin([
{ from: 'static', ignore: ['.gitkeep'] }
]),
new webpack.ProgressPlugin(),
options.dev
? new webpack.NoEmitOnErrorsPlugin()
: new ExtractTextPlugin('[name].[contenthash:7].css')
],
resolve: {
alias: {
'src': resolve(__dirname, 'src')
},
extensions: ['.js', '.vue']
},
devServer: {
host: '127.0.0.1',
port: 8010,
proxy: {
'/api/': {
target: 'http://127.0.0.1:8080',
changeOrigin: true,
pathRewrite: {
'^/api': ''
}
}
},
stats: 'errors-only',
historyApiFallback: true
},
devtool: options.dev ? '#eval-source-map' : '#source-map'
});