-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.dev-server.js
119 lines (117 loc) · 2.86 KB
/
webpack.dev-server.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
118
119
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const express = require("express");
const webpack = require("webpack");
const pkg = require("./package.json");
const config = {
entry: {
UV: ["./src/index.ts"]
},
mode: "development",
output: {
libraryTarget: "umd",
library: "UV",
umdNamedDefine: true,
chunkFilename: "[name].[contenthash].js",
globalObject: "this"
},
resolve: {
extensions: [".ts", ".tsx", ".js"]
},
module: {
rules: [
{
test: /\.ts$/,
use: [{ loader: "ts-loader" }]
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
},
{
test: /\.less$/,
use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
options: {
sourceMap: true
}
},
{
loader: "less-loader",
options: {
lessOptions: {
strictMath: true
},
additionalData: '@theme: "uv-en-gb-theme";'
}
}
]
},
{
test: /\.(png|jpg|gif|svg)$/i,
use: [
{
loader: "url-loader",
options: {
limit: 8192
}
}
]
}
]
},
devServer: {
static: path.join(__dirname),
client: {
progress: true,
},
open: true,
compress: true,
port: 8080,
onListening(devServer) {
devServer.app.use(
"/collection.json",
express.static(path.join(__dirname, "src", "collection.json"))
);
devServer.app.use(
"/uv-config.json",
express.static(path.join(__dirname, "src", "uv-config.json"))
);
devServer.app.use("/uv.css", express.static(path.join(__dirname, "src", "uv.css")));
devServer.app.use(
"/uv-assets/config",
express.static(path.join(__dirname, "dist", "uv-assets", "config"))
);
devServer.app.use(
"/uv-assets/themes",
express.static(path.join(__dirname, "dist", "uv-assets", "themes"))
);
devServer.app.use(
"/uv-assets/img",
express.static(path.join(__dirname, "dist", "uv-assets", "img"))
);
devServer.app.use(
"/uv-assets/js/bundle.js",
express.static(
path.join(__dirname, "dist", "uv-assets", "js", "bundle.js")
)
);
}
},
plugins: [
new webpack.EnvironmentPlugin({
PACKAGE_VERSION: `${pkg.version} (development)`
}),
new HtmlWebpackPlugin({
title: "UV Examples",
template: "./src/html-templates/index.html",
minify: false,
inject: "head"
})
]
};
module.exports = config;