This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
63 lines (59 loc) · 1.97 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin'); // Require html-webpack-plugin plugin
const VueLoaderPlugin = require('vue-loader/lib/plugin');
var apiHost;
var setupEnv = function(env) {
console.log("setup Env " + env["NODE_ENV"])
switch (env["NODE_ENV"]) {
case 'production':
apiHost = JSON.stringify("URL_PROD")
break;
case 'development':
apiHost = JSON.stringify("http://localhost:8080")
break;
default:
apiHost = JSON.stringify("Not defined")
break;
}
}
module.exports = env => {
setupEnv(env)
return {
entry: __dirname + "/src/app/index.js", // webpack entry point. Module to start building dependency graph
output: {
path: __dirname + '/dist', // Folder to store generated bundle
filename: 'bundle.js', // Name of generated bundle after build
publicPath: '/' // public URL of the output directory when referenced in a browser
},
plugins: [ // Array of plugins to apply to build chunk
new HtmlWebpackPlugin({
template: __dirname + "/src/public/index.html",
inject: 'body'
}),
new VueLoaderPlugin(),
new webpack.DefinePlugin({
BACKEND_URL: apiHost
})
],
devServer: { // configuration for webpack-dev-server
contentBase: './src/public', //source of static assets
port: 8080, // port to run dev-server
host: '0.0.0.0',
disableHostCheck: true
},
resolve: {
alias: {
'vue': 'vue/dist/vue.esm.js'
}
},
module: {
rules: [{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}, {
test: /\.vue$/,
loader: 'vue-loader'
}]
}
}
}