2018-08-17 21:26:32 +08:00
|
|
|
import * as webpack from 'webpack';
|
|
|
|
|
2020-05-07 10:51:27 +08:00
|
|
|
const TS_LOADER = [
|
|
|
|
{ loader: 'cache-loader', options: { cacheDirectory: "node_modules/.cache_loader" } },
|
|
|
|
{
|
|
|
|
loader: 'ts-loader',
|
|
|
|
options: {
|
|
|
|
transpileOnly: true,
|
|
|
|
experimentalWatchApi: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2018-08-17 21:26:32 +08:00
|
|
|
const config: webpack.Configuration = {
|
|
|
|
devtool: "source-map",
|
|
|
|
//项目需要解析的文件拓展名称
|
|
|
|
resolve: {
|
|
|
|
extensions: [".ts", ".tsx", ".js", "json"]
|
|
|
|
},
|
|
|
|
//模块加载器设置
|
|
|
|
module: {
|
|
|
|
rules: [
|
2023-07-13 11:57:28 +08:00
|
|
|
{
|
|
|
|
test: /\.worker\.ts$/,
|
|
|
|
exclude: /node_modules/,
|
|
|
|
use: [
|
|
|
|
{ loader: 'worker-loader', },
|
|
|
|
...TS_LOADER
|
|
|
|
]
|
|
|
|
},
|
2018-08-17 21:26:32 +08:00
|
|
|
{
|
|
|
|
test: /\.tsx?$/,
|
|
|
|
exclude: /node_modules/,
|
2020-05-07 10:51:27 +08:00
|
|
|
use: TS_LOADER,
|
2018-08-17 21:26:32 +08:00
|
|
|
},
|
2023-07-13 11:57:28 +08:00
|
|
|
{
|
|
|
|
test: /\.[(png)|(obj)|(json)]$/,
|
|
|
|
loader: "file-loader"
|
|
|
|
},
|
|
|
|
//样式加载 css
|
|
|
|
{
|
|
|
|
test: /\.css$/,
|
|
|
|
use: ['style-loader', 'css-loader']
|
|
|
|
},
|
|
|
|
//样式加载 less
|
|
|
|
{
|
|
|
|
test: /\.less$/,
|
|
|
|
use: [
|
|
|
|
{ loader: "style-loader" },
|
|
|
|
{ loader: 'css-loader', options: { sourceMap: false } },
|
|
|
|
{
|
|
|
|
loader: "less-loader",
|
|
|
|
options: {
|
|
|
|
lessOptions: {
|
|
|
|
strictMath: true,
|
|
|
|
noIeCompat: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
//字体加载 blueprint
|
|
|
|
{
|
|
|
|
test: /\.(ttf|eot|svg|FBX)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'file-loader',
|
|
|
|
options: { name: 'fonts/[contenthash].[ext]' }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
//字体加载 blueprint
|
|
|
|
{
|
|
|
|
test: /\.(woff|woff2|jpg|png)$/,
|
|
|
|
use: {
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
name: 'fonts/[contenthash].[ext]',
|
|
|
|
limit: 5000,
|
|
|
|
mimetype: 'application/font-woff'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(glsl|vs|fs)$/,
|
|
|
|
loader: 'shader-loader'
|
|
|
|
}
|
2018-08-17 21:26:32 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
]
|
2023-07-13 11:57:28 +08:00
|
|
|
};
|
2018-08-17 21:26:32 +08:00
|
|
|
|
|
|
|
export default config;
|