forked from baizn/g6-in-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
100 lines (99 loc) · 2.31 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
const webpack = require("webpack");
const path = require("path");
// eslint-disable-next-line prefer-destructuring
const resolve = path.resolve;
const HTMLPlugin = require("html-webpack-plugin");
const UglifyJSWebpackPlguin = require("uglifyjs-webpack-plugin");
module.exports = {
entry: {
g6InReact: [
"webpack-dev-server/client?http://localhost:8080",
"./pages/index.js",
],
},
output: {
filename: "[name].min.js",
library: "G6",
libraryTarget: "umd",
libraryExport: "default",
path: resolve(process.cwd(), "dist/"),
},
target: "web",
resolve: {
// Add `.ts` as a resolvable extension.
extensions: [".ts", ".js"],
},
module: {
rules: [
{
test: /\.less$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: {
sourceMap: true,
},
},
{
loader: "less-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.(js|jsx)$/,
use: {
loader: "babel-loader",
options: {
babelrc: true,
},
},
},
{
test: /\.(ts|tsx)$/,
use: {
loader: "ts-loader",
options: {
transpileOnly: true,
},
},
},
{
test: /\.css$/,
loader: "style-loader!css-loader",
},
{
test: /\.(png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/,
loader: "file-loader",
},
],
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.AggressiveMergingPlugin(),
new HTMLPlugin({
template: "./pages/index.html",
}),
// 更多配置项参考:https://www.webpackjs.com/plugins/uglifyjs-webpack-plugin/
new UglifyJSWebpackPlguin({
exclude: /node_modules/,
uglifyOptions: {
ecma: 5,
ie8: true,
},
}),
],
devtool: "cheap-module-eval-source-map",
devServer: {
// 本地测试服务器加载的页面所在的目录,默认webpack-dev-server会为根文件夹提供本地服务器
// contentBase: "./test-server",
contentBase: "./dist",
// 监听的端口,默认为8080
port: 8080,
// 不跳转
historyApiFallback: true,
},
};