This repository has been archived by the owner on Aug 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.front.config.js
117 lines (111 loc) · 3.4 KB
/
webpack.front.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
113
114
115
116
117
// webpack.config.js
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin')
const autoprefixer = require('autoprefixer');
module.exports = function () {
const config = {
name: 'front',
entry: './src/index.js',
mode: 'development',
externals: {
'vue': 'Vue'
},
devtool: 'inline-source-map',
devServer: {
contentBase: './dist',
"hot": true,
headers: {
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
"Access-Control-Allow-Origin": "*"
}
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.vue$/,
loader: 'weweb-strip-block',
options: {
blocks: [
{
start: 'wwManager:start',
end: 'wwManager:end'
}
]
}
},
// this will apply to both plain `.js` files
// AND `<script>` blocks in `.vue` files
{
test: /\.js$/,
loader: 'babel-loader'
},
// this will apply to both plain `.css` files
// AND `<style>` blocks in `.vue` files
{
test: /\.(css|scss)$/,
use: [
'vue-style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
plugins: function () {
return [autoprefixer]
}
}
},
'sass-loader',
]
},
{
test: /\.(png|jpg|gif)$/i,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
}
]
},
output: {
path: path.join(__dirname, "dist"),
filename: "front.js"
},
plugins: [
// make sure to include the plugin for the magic
new VueLoaderPlugin()
]
}
function findPara(param) {
let result = '';
process.argv.forEach((argv) => {
if (argv.indexOf('--' + param) === -1) return;
result = argv.split('=')[1];
});
return result;
}
let port = findPara('port');
try {
port = parseInt(port);
}
catch (e) {
port = null;
}
if (port) {
config.devServer.port = port;
config.output.publicPath = 'https://localhost:' + port + '/';
}
else {
console.log('\x1b[41mPLEASE DEFINE A PORT (ex : --port=8080)\x1b[0m');
return null;
}
return config;
}