1 Star 0 Fork 0

jiaxon/lowcode-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.plugin.js 1.83 KB
一键复制 编辑 原始数据 按行查看 历史
const fs = require('fs-extra');
const configuration = require('./build.json');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { version } = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
module.exports = ({ onGetWebpackConfig }) => {
onGetWebpackConfig((config) => {
config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [
{
configFile: './tsconfig.json',
},
]);
config.merge({
node: {
fs: 'empty',
},
});
const entries = Object.keys(configuration.entry) || [];
entries.map((entry) => {
const [scenarioName, page] = entry.split('/');
if (page === 'index') {
config
.plugin(entry)
.use(HtmlWebpackPlugin, [
{
inject: false,
minify: false,
templateParameters: {
version,
scenarioName
},
template: require.resolve('./public/index.ejs'),
filename: `${scenarioName}/index.html`,
},
]);
}
if (page === 'preview') {
config
.plugin(entry)
.use(HtmlWebpackPlugin, [
{
inject: false,
minify: false,
templateParameters: {
scenarioName,
},
template: require.resolve('./public/preview.html'),
filename: `${scenarioName}/preview.html`,
},
]);
}
})
config.plugins.delete('hot');
config.devServer.hot(false);
config.module // fixes https://github.com/graphql/graphql-js/issues/1272
.rule('mjs$')
.test(/\.mjs$/)
.include
.add(/node_modules/)
.end()
.type('javascript/auto');
});
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/jiaxon/lowcode-demo.git
git@gitee.com:jiaxon/lowcode-demo.git
jiaxon
lowcode-demo
lowcode-demo
main

搜索帮助