1 Star 0 Fork 0

许其勇/jowo-component-highcharts

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
webpack.pack.config.js 4.37 KB
一键复制 编辑 原始数据 按行查看 历史
jeffrey6052 提交于 2022-03-25 18:41 . 基础Highcharts组件
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'production';
process.env.NODE_ENV = 'production';
const path = require('path')
const TerserPlugin = require('terser-webpack-plugin')
const CleanWebpackPlugin = require('clean-webpack-plugin')
const AmdWebpackPlugin = require('amd-webpack-plugin')
const ZipPlugin = require('zip-webpack-plugin');
const CopyPlugin = require("copy-webpack-plugin")
const { v4: uuidv4 } = require('uuid');
const jsonpFunctionName = "webpackJsonp_" + uuidv4().replace(/-/g, '');
const getOptions = () => {
return {
mode: 'production',
entry: "./src/system/main.js",
output: {
path: path.resolve(__dirname, './dist'),
filename: 'components.js',
chunkFilename: '[name].js',
libraryTarget: "amd",
jsonpFunction: jsonpFunctionName
},
externals: [
externalForJowoStudio
],
module: {
rules: [
{ parser: { requireEnsure: true } },
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react']
}
}
},
{
test: /\.module\.css$/,
loader: "style-loader!css-loader?modules"
},
{
test: /\.css$/,
exclude: /\.module\.css$/,
loader: "style-loader!css-loader"
},
{
test: /\.(png|jpe?g|jfif|gif|svg|eot|ttf|woff|woff2)$/i,
loader: 'url-loader',
options: {
limit: Infinity
},
}
].filter(Boolean)
},
plugins: [
new CleanWebpackPlugin(['./dist']),
new CopyPlugin([
{
from: path.resolve(__dirname, "public", "static"),
to: "static",
}
]),
new AmdWebpackPlugin({
wrapper: 'define',
hashedModuleIds: false
}),
new ZipPlugin({
filename: 'dist.zip'
})
].filter(Boolean),
optimization: {
splitChunks: {
chunks: 'all',
minSize: 500000,
maxSize: 500000,
minChunks: 1,
cacheGroups: {
default: false,
vendors: false,
// choose other node_modules to be vendor.js
vendor: {
name: 'vendor',
chunks: 'all',
minChunks: 1,
test: /[\\/]node_modules[\\/]/,
priority: 10
}
}
},
minimize: true,
minimizer: [new TerserPlugin({
extractComments: false,
terserOptions: {
format: {
comments: false,
},
}
})]
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src')
}
}
}
}
module.exports = getOptions
const externalsMap = {
'react': 'React',
'react-dom': 'ReactDOM',
'react-router-dom': 'ReactRouterDOM',
'react-router': 'ReactRouterDOM',
'tinycolor2': 'tinycolor',
'antd': 'antd',
'moment': 'moment',
'lodash': '_',
'echarts': 'echarts',
'axios': 'axios',
"@material-ui/core": "MaterialUI",
"@material-ui/core/styles": "MaterialUI",
"@material-ui/core/utils": "MaterialUI"
}
function externalForJowoStudio(context, request, callback) {
var externalName = externalsMap[request]
if (externalName) {
return callback(null, externalName);
} else {
var materialUIMatched = /@material-ui\/core\/(.+)/g.exec(request)
if (materialUIMatched) {
const name = materialUIMatched[1]
return callback(null, 'MaterialUI.' + name);
} else {
return callback();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jowoiot_qiyong_xu/jowo-component-highcharts.git
git@gitee.com:jowoiot_qiyong_xu/jowo-component-highcharts.git
jowoiot_qiyong_xu
jowo-component-highcharts
jowo-component-highcharts
master

搜索帮助