-
Notifications
You must be signed in to change notification settings - Fork 7
/
webpack.config.js
75 lines (74 loc) · 1.71 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
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const version = process.env.npm_package_version;
const mode = (process.argv[2].split('=')[1]);
const dev = mode == "development";
let compilePath = {
test: './src/core/test.ts'
}
const output = dev ? 'debug' : 'example/image-preview';
var plugins = [new HtmlWebpackPlugin({
title: 'this is dev mode!',
template: './debug/template.html'
})];
if(dev){
plugins.push(new webpack.HotModuleReplacementPlugin({}))
}
module.exports = {
mode,
entry: compilePath,
module: {
rules: [
{
test: /\.(frag)|(vert)/,
use: [
{
loader: path.resolve(__dirname, 'scripts/shader-loader.js'),
},
],
exclude: /node_modules/
},
{
test: /\.ts$/,
use: [{
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.json')
}
}],
exclude: /node_modules/
},
]
},
output: {
filename: `[name]${version}.js`,
path: path.resolve(__dirname, output)
},
devServer: {
contentBase: './debug',
hot: true,
host: getIp(),
port: 9999,
open: true
},
plugins: plugins,
resolve: {
alias: {
vue: 'vue/dist/vue.js'
},
extensions: ['.ts', '.js']
}
};
function getIp() {
var interfaces = require('os').networkInterfaces();
for (var devName in interfaces) {
var iface = interfaces[devName];
for (var i = 0; i < iface.length; i++) {
var alias = iface[i];
if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
return alias.address;
}
}
}
}