forked from ModelEngine-Group/app-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.common.single.js
More file actions
172 lines (169 loc) · 4.71 KB
/
Copy pathwebpack.common.single.js
File metadata and controls
172 lines (169 loc) · 4.71 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/*---------------------------------------------------------------------------------------------
* Copyright (c) 2025 Huawei Technologies Co., Ltd. All rights reserved.
* This file is a part of the ModelEngine Project.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const rootPath = path.resolve(__dirname, './');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
context: rootPath,
entry: {
main: path.resolve(rootPath, 'src/index.tsx'),
},
output: {
publicPath: '/',
clean: true,
path: path.resolve(rootPath, 'build'),
filename: '[name].js',
chunkFilename: '[name].js',
library: {
type: 'module',
},
assetModuleFilename: 'assets/images/[name][ext]',
},
experiments: {
outputModule: true
},
externalsType: 'module',
module: {
rules: [{
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 200 * 1024, // 200kb
},
},
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(j|t)sx?$/,
exclude: /node_modules/,
include: [path.resolve(rootPath, 'src')],
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/preset-react',
'@babel/preset-typescript',
],
plugins: [
[
require.resolve('babel-plugin-import'),
{
libraryName: '@iux/live-react',
style: true,
},
],
],
},
},
},
{
test: /\.s(c|a)ss$/,
include: [path.resolve(rootPath, 'src')],
exclude: /node_modules/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
url: false,
sourceMap: true,
importLoaders: 2,
modules: {
auto: true,
exportLocalsConvention: 'dashesOnly',
localIdentName: '[local]__[hash:base64:5]',
},
},
},
'postcss-loader',
{
loader: 'sass-loader',
},
],
},
{
test: /\.less$/,
use: [
'style-loader',
{
loader: 'css-loader',
options: {
esModule: true,
modules: {
auto: true,
exportLocalsConvention: 'dashesOnly',
localIdentName: '[local]__[hash:base64:5]',
},
importLoaders: 2,
},
},
'postcss-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
modifyVars: {
'primary-color': '#2673e5',
'border-radius-base': '4px',
'tag-default-bg': '#f2f2f2',
'disabled-color': '#808080',
'primary-color-hover': '#2673e5',
'select-item-selected-color': '#2673e5',
'select-item-selected-bg': '#2673e50f',
'select-item-selected-font-weight': 'normal',
'outline-blur-size': '0',
'outline-width': '0',
'input-hover-border-color': '#4d4d4d',
'error-color': '#c63939',
'drawer-body-padding': '16px 24px',
},
javascriptEnabled: true,
},
},
},
],
},
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
alias: {
'@': path.resolve(rootPath, 'src'),
},
fallback: {
'react/jsx-runtime': 'react/jsx-runtime.js',
'react/jsx-dev-runtime': 'react/jsx-dev-runtime.js',
},
},
plugins: [
new HtmlWebpackPlugin({
title: 'ModeEngine',
template: path.resolve(rootPath, 'src/index.html'),
publicPath: '',
chunks: ['main'],
scriptLoading: 'module'
}),
new CopyWebpackPlugin({
patterns: [
{
from: 'src/assets', // 静态资源目录
to: 'src/assets', // 打包后的静态资源目录
globOptions: {
ignore: ['**/icon.*'], // 忽略的文件
},
},
{
from: 'plugins', // 插件目录
to: 'plugins', // 打包后的插件目录
}
],
}),
],
};