-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
100 lines (97 loc) · 2.4 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
let path = require('path');
let webpack = require('webpack');
let dotenv = require('dotenv');
dotenv.config({ path: './.env.'+ process.env.NODE_ENV, debug: true })
let config = {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV),
'BASE_URL': JSON.stringify(process.env.BASE_URL),
'VUE_APP_TITLE': JSON.stringify(process.env.VUE_APP_TITLE),
'VUE_APP_ENVIRONMENT': JSON.stringify(process.env.VUE_APP_ENVIRONMENT),
'VUE_APP_SERVER_URL': JSON.stringify(process.env.VUE_APP_SERVER_URL),
}
console.log("The generated config is: " + JSON.stringify(config))
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist/'),
publicPath: process.env.BASE_URL,
filename: 'build.js'
},
plugins: [
new webpack.DefinePlugin({
config: config,
BASE_URL: JSON.stringify(process.env.BASE_URL),
}),
],
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpe?g|gif|svg|jpg)$/,
use: [
{
loader: 'file-loader',
options: {
name: '[name].[contenthash].[ext]',
outputPath: './assets',
esModule: false
}
}
]
},
{
test: /\.(eot|ttf|woff|woff2)$/,
loader: 'file-loader?name=public/fonts/[name].[ext]'
},
{
test: /\.s[ac]ss$/i,
use: [
// convert Vue <style> tags into css
'vue-style-loader',
// Creates `style` nodes from JS strings
'style-loader',
// Translates CSS into CommonJS
'css-loader',
// Compiles Sass to CSS
'sass-loader',
],
},
{
parser: {
amd: false
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true,
open: true,
},
performance: {
hints: false
},
devtool: '#eval-source-map'
};