-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
117 lines (117 loc) · 3.76 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const pkg = require("./package.json");
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const {CleanWebpackPlugin} = require("clean-webpack-plugin");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
const banner = new webpack.BannerPlugin({
banner: `
YzPlatForm v${pkg.version}
provide the native function call API of yunzai mobile platform for the third party.
Copyright (c) 2019 河北云在, ${pkg.repository.url}
`,
entryOnly: true
});
module.exports = {
watch: false,
mode: "production",
entry: "./src/umd.ts",
output: {
path: path.resolve(__dirname, "dist/yz-native-js-sdk/"),
filename: "[name].bundle.js",
chunkFilename: "[name].bundle.js",
libraryTarget: "umd",
library: "YzDevice",
libraryExport: "default"
},
resolve: {
extensions: [".js", ".ts", ".svg", ".png", ".scss", "less", "jpeg", ".css"]
},
module: {
rules: [
{
test: /\.html$/,
use: [
{
loader: "html-loader",
options: {
minimize: false
}
}
]
},
{
test: /\.(png|svg|jpeg|jpg|gif)$/,
use: [
{
loader: "file-loader",
options: {
name: "[name]",
publicPath: "./assets/image/",
outputPath: "assets/image/"
}
}
]
},
{
test: /\.less$/,
use: ["style-loader", "css-loader", "less-loader", "postcss-loader"]
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader", "postcss-loader"]
},
{
test: /\.js$/,
exclude: "/node_modules/",
use: {
loader: "babel-loader",
options: {
presets: [
[
"@babel/env",
{
targets: {
browsers: [
"last 2 Chrome major versions",
"last 2 Firefox major versions",
"last 2 Safari major versions",
"last 2 Edge major versions",
"last 2 iOS major versions",
"last 2 ChromeAndroid major versions"
]
}
}
]
]
}
}
},
{
test: /\.ts$/,
use: "ts-loader"
}
]
},
plugins: [
banner,
new CopyPlugin([
{from: "./src/sdk.js", to: "sdk.js"},
{from: "package.json", to: "package.json"},
{from: 'README.md', to: "README.md"}
]
),
new HtmlWebpackPlugin({
title: "APP_NATIVE_SCRIPT",
template: "./src/index.html"
}),
new CleanWebpackPlugin()
],
devServer: {
contentBase: path.join(__dirname, "./dist"),
port: 4200,
host: "0.0.0.0",
historyApiFallback: true,
hot: true
}
};