-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
102 lines (97 loc) · 3.06 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
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require('webpack');
const path = require("path");
// GET CONFIG FROM .ENV
require('dotenv').config();
process_env = {};
Object.keys(process.env).map( k => process_env[k] = JSON.stringify(process.env[k]) );
// CONSOLE SUMMARY
console.log('\n-----------');
console.log("APP:\t\t", process.env.appName);
console.log("VERSION:\t", process.env.version);
console.log("ENVIRONMENT:\t", process.env.environment);
console.log('-----------\n\n');
// WEBPACK SETTINGS
module.exports = function (env, argv) {
return {
mode: process.env ? process.env.environment : 'production',
devtool: process.env && process.env.environment === 'production' ? 'source-maps' : 'eval',
context: path.join(__dirname, "/src"),
devServer: {
contentBase: path.join(__dirname, "dist"),
watchContentBase: true,
compress: true,
lazy: false,
open: true,
overlay: true,
host: '0.0.0.0',
port: 1337,
},
entry: {
app: "./main.js",
},
output: {
path: path.join(__dirname, "/dist"),
filename: "[name].bundle.js",
},
plugins: [
new VueLoaderPlugin(),
new webpack.DefinePlugin({
'process.env': process_env
}),
new CopyWebpackPlugin([
{ from: '../static' }
]),
],
node: {
fs: "empty",
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'@': path.join(__dirname, "/src"),
'vue$': 'vue/dist/vue.esm.js'
},
},
module: {
rules: [{
test: /\.jsx?$/,
exclude: /^node_modules$/,
use: [{
loader: "babel-loader",
options: {
presets: ["env"],
plugins:[ 'transform-object-rest-spread' ],
},
}],
},
{
test: /index\.html$/,
loader: "file-loader",
options: {
name: "index.html",
}
},
{
test: /\.css$/,
use: ['vue-style-loader', 'style-loader', 'css-loader'],
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', "sass-loader"],
},
{
test: /\.vue$/,
loader: "vue-loader",
},{
test: /\.(png|jpg|webp|gif|ico)$/,
use: "url-loader",
},{
test: /\.svg$/,
use: "file-loader",
},
],
},
};
};