2018-11-19 15:13:48 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
2020-06-12 15:55:04 +08:00
|
|
|
*
|
2018-11-19 15:13:48 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2020-06-12 15:55:04 +08:00
|
|
|
*
|
2018-11-19 15:13:48 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2020-06-12 15:55:04 +08:00
|
|
|
*
|
2018-11-19 15:13:48 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2018-11-18 13:58:33 +08:00
|
|
|
const path = require('path');
|
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
|
|
|
|
|
|
const isDev = process.env.NODE_ENV !== 'production';
|
|
|
|
|
|
|
|
function resolve(dir) {
|
|
|
|
return path.join(__dirname, '..', dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
entry: {
|
|
|
|
main: './src/index.js',
|
|
|
|
},
|
|
|
|
output: {
|
2018-11-22 14:29:48 +08:00
|
|
|
filename: './js/[name].js',
|
2018-11-18 13:58:33 +08:00
|
|
|
path: path.resolve(__dirname, '../dist'),
|
|
|
|
},
|
|
|
|
resolve: {
|
2019-03-13 17:34:01 +08:00
|
|
|
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
|
2018-11-18 13:58:33 +08:00
|
|
|
alias: {
|
|
|
|
'@': resolve('src'),
|
2018-11-20 14:39:46 +08:00
|
|
|
utils: resolve('src/utils'),
|
|
|
|
components: resolve('src/components'),
|
2018-11-18 13:58:33 +08:00
|
|
|
},
|
|
|
|
},
|
2020-06-29 15:43:07 +08:00
|
|
|
externals: {
|
|
|
|
jquery: 'jQuery'
|
|
|
|
},
|
2019-04-19 17:55:43 +08:00
|
|
|
node: {
|
|
|
|
fs: 'empty'
|
|
|
|
},
|
2018-11-18 13:58:33 +08:00
|
|
|
module: {
|
2018-11-20 14:39:46 +08:00
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.(css|scss)$/,
|
2022-04-18 11:27:39 +08:00
|
|
|
use: [isDev ? 'style-loader' : MiniCssExtractPlugin.loader, {
|
|
|
|
loader: 'css-loader',
|
|
|
|
options:{
|
|
|
|
url: (url) => {
|
|
|
|
return isDev || !url.includes("console-ui");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 'sass-loader'],
|
2018-11-18 13:58:33 +08:00
|
|
|
},
|
2018-11-20 14:39:46 +08:00
|
|
|
{
|
|
|
|
test: /\.(js|jsx)$/,
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
enforce: 'pre',
|
|
|
|
include: [resolve('src')],
|
|
|
|
},
|
|
|
|
{
|
2019-03-13 17:34:01 +08:00
|
|
|
test: /\.(js|jsx|ts|tsx)$/,
|
2018-11-20 14:39:46 +08:00
|
|
|
include: [resolve('src')],
|
|
|
|
use: ['babel-loader'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
2018-11-18 13:58:33 +08:00
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
2018-11-20 14:39:46 +08:00
|
|
|
limit: 10000,
|
|
|
|
name: '/img/[name].[hash:8].[ext]',
|
2018-11-18 13:58:33 +08:00
|
|
|
},
|
2018-11-20 14:39:46 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.(ttf|woff|svg)$/,
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'url-loader',
|
|
|
|
options: {
|
|
|
|
name: '/fonts/[name].[hash:8].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
2018-11-18 13:58:33 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
filename: 'index.html',
|
2022-04-20 10:20:26 +08:00
|
|
|
template: './public/index.ejs',
|
|
|
|
templateParameters: {
|
|
|
|
contextPath: isDev ? './' : 'console-ui/public/'
|
|
|
|
},
|
|
|
|
hash: true,
|
2018-11-18 13:58:33 +08:00
|
|
|
minify: !isDev,
|
|
|
|
}),
|
2018-11-20 14:39:46 +08:00
|
|
|
new CopyWebpackPlugin([
|
|
|
|
{
|
2020-11-12 09:18:45 +08:00
|
|
|
from: resolve('../console/src/main/resources/static/console-ui/public'),
|
2018-11-20 14:39:46 +08:00
|
|
|
to: './',
|
|
|
|
ignore: ['index.html'],
|
|
|
|
},
|
|
|
|
]),
|
2018-11-18 13:58:33 +08:00
|
|
|
],
|
|
|
|
};
|