代码拉取完成,页面将自动刷新
// 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();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。