3cx_tapi/config/webpack.config.base.cjs

52 lines
964 B
JavaScript
Raw Permalink Normal View History

2020-11-04 22:59:32 +01:00
const path = require('path')
2021-08-27 18:12:26 +02:00
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
2020-11-04 22:59:32 +01:00
const webpackConfig = {
resolve: {
extensions: ['.js', '.ts']
},
optimization: {
2021-08-27 18:12:26 +02:00
minimize: false,
moduleIds: 'named',
2020-11-04 22:59:32 +01:00
},
2021-08-27 18:12:26 +02:00
entry: './src/index.js',
2020-11-04 22:59:32 +01:00
output: {
path: path.resolve(__dirname, '../dist')
},
externals: {
2021-08-27 18:12:26 +02:00
jquery: '$',
2020-11-04 22:59:32 +01:00
},
module: {
rules: [
{
2021-08-27 18:12:26 +02:00
use: {
loader: 'babel-loader',
},
2020-11-04 22:59:32 +01:00
test: /\.js$/,
},
{
test: /\.ts$/,
loader: 'ts-loader'
},
{
test: /\.less$/,
2021-08-27 18:12:26 +02:00
use: [
2020-11-04 22:59:32 +01:00
'style-loader',
'css-loader',
'less-loader', // 将 Less 编译为 CSS
]
},
{
test: /\.css$/,
2021-08-27 18:12:26 +02:00
use: [
2020-11-04 22:59:32 +01:00
'style-loader',
'css-loader',
]
}
]
},
2021-08-27 18:12:26 +02:00
plugins: process.env.npm_config_report ? [new BundleAnalyzerPlugin()] : [],
2020-11-04 22:59:32 +01:00
}
module.exports = webpackConfig