1 Star 0 Fork 1

stephenchin/lowcode-demo1

forked from RobinMa/lowcode-demo1 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
build.plugin.js 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
mazj 提交于 2022-07-17 13:34 . feat: init
const { join } = require('path');
const fs = require('fs-extra');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const scenarioNames = fs.readdirSync(join('./src/scenarios')).filter(name => !name.startsWith('.'));
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',
},
});
scenarioNames.forEach(name => {
const hasTsx = fs.existsSync(join(`./src/scenarios/${name}/index.tsx`));
config.merge({
entry: {
[name]: hasTsx ? require.resolve(`./src/scenarios/${name}/index.tsx`) : require.resolve(`./src/scenarios/${name}/index.ts`),
},
});
config
.plugin(name)
.use(HtmlWebpackPlugin, [
{
inject: false,
minify: false,
templateParameters: {
scenario: name,
version,
},
template: require.resolve('./public/index.ejs'),
filename: `${name}.html`,
},
]);
})
config
.plugin('preview')
.use(HtmlWebpackPlugin, [
{
inject: false,
templateParameters: {
},
template: require.resolve('./public/preview.html'),
filename: '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 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/qxy/lowcode-demo1.git
git@gitee.com:qxy/lowcode-demo1.git
qxy
lowcode-demo1
lowcode-demo1
master

搜索帮助