forked from adriangigante/rating-web
-
Notifications
You must be signed in to change notification settings - Fork 188
/
webpack.config.js
executable file
·112 lines (110 loc) · 2.59 KB
/
webpack.config.js
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
110
111
112
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CompressionPlugin = require("compression-webpack-plugin");
const API = process.env.API;
var onError = function (err, req, res) {
console.log('Error with webpack proxy :', err);
};
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
use: [{
loader: 'vue-loader',
options: {
loaders: {
'scss': 'vue-style-loader!css-loader!sass-loader',
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
}
}
}]
},
{
test: /\.js$/,
use: ['babel-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader']
},
{
test: /\.(png|jpg|jpeg|gif|svg|eot|ttf|woff|woff2)$/,
use: [{
loader: 'url-loader',
options: {
name: '[name].[ext]?[hash]',
limit: 10000
}
}]
}
]
},
resolve: {
extensions: ['.js', '.vue'],
modules: [
'node_modules'
],
alias: {
'vue$': 'vue/dist/vue.esm.js'
}
},
devtool: '#eval-source-map',
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$|\.png$|\.jpg$|\.ico$/,
threshold: 10240,
minRatio: 0.8
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
'process.env.SITE_CODE': JSON.stringify(process.env.SITE_CODE),
'process.env.API': JSON.stringify(process.env.API)
})
],
devServer: {
headers: {
'Access-Control-Allow-Origin': '*',
},
host: '0.0.0.0',
disableHostCheck: true,
port: 8080,
before(app) {
app.use((req, res, next) => {
console.log(`ENV API: `, process.env.API);
console.log(`Using middleware for ${req.url}`);
next();
});
},
noInfo: false,
historyApiFallback: {
index: '/dist/'
},
proxy: {
'/api': {
target: API
},
onError: onError,
logLevel: 'debug'
}
}
};