amis-rpc-design/build/webpack.dev.js

90 lines
2.4 KiB
JavaScript
Raw Normal View History

2023-10-07 19:42:30 +08:00
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {CleanWebpackPlugin} = require('clean-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
module.exports = {
mode: 'development',
entry: {
index: path.resolve(__dirname, '../src/index.tsx')
},
module: {
// modulePathIgnorePatterns: ['libs'],
rules: [
// {
// test: /\.tsx?$/,
// use: [
// {
// loader: 'ts-loader',
// options: {
// transpileOnly: true
// }
// }
// ],
// include: path.resolve(__dirname, '../src')
// },
{
test: /\.(ts|tsx)$/,
include: [path.resolve(__dirname, '../src')],
enforce: 'pre',
use: ['babel-loader']
},
{
test: /\.woff2?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
use: 'url-loader?limit=10000',
include: path.resolve(__dirname, '../src')
},
{
test: /\.(ttf|eot|svg)(\?[\s\S]+)?$/,
use: 'file-loader',
include: path.resolve(__dirname, '../src')
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
// include: path.resolve(__dirname, '../src')
},
{
test: /\.ttf$/,
use: ['file-loader']
}
]
},
plugins: [
new CleanWebpackPlugin({cleanStaleWebpackAssets: false}),
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './template.html'),
}),
new MonacoWebpackPlugin(),
new ForkTsCheckerWebpackPlugin(),
new ReactRefreshWebpackPlugin(),
],
resolve: {
extensions: ['.tsx', '.ts', '.js', '.html'],
modules: [
'node_modules',
path.resolve(__dirname, '../libs/amis/packages')
],
alias: {
"@amis": path.resolve(__dirname, '../libs/amis/packages')
}
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.join(__dirname, '../dist'),
publicPath: path.join(__dirname, '../dist'),
compress: true,
port: 9000,
hot: true,
proxy: {
'/api': 'http://localhost:3000'
}
},
output: {
filename: '[name].bundle.js',
publicPath: '/',
path: path.resolve(__dirname, '../dist')
}
};