-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
69 lines (66 loc) · 1.57 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
const HtmlWebpackPlugin = require("html-webpack-plugin")
const ExtractTextPlugin = require("extract-text-webpack-plugin")
const CleanCSSPlugin = require("less-plugin-clean-css")
const path = require("path")
const extractLess = new ExtractTextPlugin("style.min.css")
const { WebpackConfig, templateContent } = require("@saber2pr/webpack-configer")
module.exports = WebpackConfig({
mode: "production",
entry: "./src/app.tsx",
resolve: {
extensions: [".js", ".jsx", ".ts", ".tsx"],
alias: {
react: "@saber2pr/react",
"react-dom": "@saber2pr/react"
}
},
output: {
filename: "bundle.min.js",
path: path.join(__dirname, "example")
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
use: ["ts-loader"]
},
{
test: /\.(css|less)$/,
use: extractLess.extract({
use: [
{
loader: "css-loader"
},
{
loader: "less-loader",
options: {
plugins: [
new CleanCSSPlugin({
advanced: true
})
]
}
}
],
fallback: "style-loader"
})
},
{
test: /\.(woff|svg|eot|ttf)$/,
use: ["url-loader"]
}
]
},
plugins: [
new HtmlWebpackPlugin({
templateContent: templateContent("@saber2pr/tree", {
injectBody: '<div id="root"></div>'
})
}),
extractLess
],
watchOptions: {
aggregateTimeout: 1000,
ignored: /node_modules|lib/
}
})