mirror of
https://github.com/didi/KnowStreaming.git
synced 2025-12-24 11:52:08 +08:00
kafka-manager 2.0
This commit is contained in:
126
kafka-manager-console/webpack.config.js
Normal file
126
kafka-manager-console/webpack.config.js
Normal file
@@ -0,0 +1,126 @@
|
||||
// https://github.com/gaearon/react-hot-loader/blob/master/examples/typescript/webpack.config.babel.js
|
||||
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
||||
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
||||
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const TerserJSPlugin = require('terser-webpack-plugin');
|
||||
const path = require('path')
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const outPath = path.resolve('../kafka-manager-web/src/main/resources/templates');
|
||||
const filename = isProd ? '[name].[contenthash]' : '[name]';
|
||||
|
||||
let publicPath = '/';
|
||||
|
||||
const plugins = [
|
||||
new HtmlWebpackPlugin({
|
||||
template: './src/routers/index.htm',
|
||||
favicon: './src/assets/image/logo.ico'
|
||||
}),
|
||||
];
|
||||
|
||||
if (isProd) {
|
||||
plugins.push(new MiniCssExtractPlugin({
|
||||
filename: `${filename}.css`,
|
||||
}), new CleanWebpackPlugin());
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
mode: isProd ? 'production' : 'development',
|
||||
entry: {
|
||||
home: [
|
||||
'./src/routers/index.tsx',
|
||||
],
|
||||
},
|
||||
output: {
|
||||
filename: `${filename}.js`,
|
||||
path: outPath,
|
||||
publicPath,
|
||||
},
|
||||
devtool: isProd ? 'none' : 'cheap-module-eval-source-map',
|
||||
plugins,
|
||||
resolve: {
|
||||
alias: {
|
||||
'react-dom': '@hot-loader/react-dom',
|
||||
},
|
||||
extensions: ['.ts', '.tsx', '.js', 'jsx', '.json'],
|
||||
plugins: [
|
||||
new TsconfigPathsPlugin(),
|
||||
],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(css|less)$/,
|
||||
use: [ isProd ? {
|
||||
loader: MiniCssExtractPlugin.loader,
|
||||
options: {
|
||||
publicPath,
|
||||
},
|
||||
} : 'style-loader', 'css-loader', {
|
||||
loader: 'less-loader',
|
||||
options: {
|
||||
javascriptEnabled: true,
|
||||
modifyVars: {
|
||||
'primary-color': '#f38031',
|
||||
'link-color': '#f38031',
|
||||
'font-size-base': '12px',
|
||||
// 'border-radius-base': '2px',
|
||||
},
|
||||
},
|
||||
}],
|
||||
},
|
||||
{
|
||||
test: /\.(ts|tsx)?$/,
|
||||
loader: 'ts-loader',
|
||||
},
|
||||
{
|
||||
test:/\.(png|svg|jpeg|jpg|gif)$/,
|
||||
use:[
|
||||
{
|
||||
loader:'file-loader',
|
||||
options:{
|
||||
name:'[name].[ext]',
|
||||
outputPath:'./assets/image/',
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimize: isProd,
|
||||
minimizer: [new TerserJSPlugin({}), new OptimizeCSSAssetsPlugin({})],
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
antd: {
|
||||
test: /[\\/]node_modules[\\/](antd|rc-|@ant-design)/,
|
||||
name: 'antd',
|
||||
chunks: 'all',
|
||||
priority: -1,
|
||||
},
|
||||
vendors: {
|
||||
test: /[\\/]node_modules[\\/]/,
|
||||
name: 'vendors',
|
||||
chunks: 'all',
|
||||
enforce: true,
|
||||
priority: -3,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
devServer: {
|
||||
contentBase: outPath,
|
||||
host: '127.0.0.1',
|
||||
port: 1025,
|
||||
hot: true,
|
||||
disableHostCheck: true,
|
||||
historyApiFallback: true,
|
||||
proxy: {
|
||||
'/api/v1/': {
|
||||
target: 'http://127.0.0.1:8080',
|
||||
changeOrigin: true,
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user