代码拉取完成,页面将自动刷新
const path = require('path');
const resolve = filePath => path.resolve(__dirname, './', filePath);
const { DefinePlugin } = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const { mockDevServer } = require("./server/server");
const bodyParser = require('body-parser');
const outputDir = 'dist';
const port = '3377';
const globalComponentPrefix = 'pl';
const config = {
publicPath: '/plain-document/', // 部署路径
buildTime: (() => {
const dateObj = new Date();
return `${dateObj.getFullYear()}-${String(dateObj.getMonth() + 1).padStart(2, '0')}-${String(dateObj.getDate()).padStart(2, '0')} ${String(dateObj.getHours()).padStart(2, '0')}:${String(dateObj.getMinutes()).padStart(2, '0')}:${String(dateObj.getSeconds()).padStart(2, '0')}`;
})()
};
module.exports = {
publicPath: config.publicPath,
outputDir: resolve(outputDir),
lintOnSave: false,
devServer: {
port,
/*避免更新静态文件时刷新页面*/
liveReload: false,
before(app) {
app.use(bodyParser.json());
mockDevServer(app, { publicPath: config.publicPath });
},
},
pages: {
index: {
entry: resolve('src/pages/index/main.tsx'),
template: 'public/index.html',
filename: 'index.html',
title: 'plain-document',
chunks: ['chunk-vendors', 'chunk-common', 'index'],
},
},
css: {
sourceMap: false,
loaderOptions: {
sass: {
prependData: `$prefix:'${globalComponentPrefix}'; @import "node_modules/plain-design/src/packages/styles/global.import.scss";`
}
},
},
configureWebpack: {
plugins: [
new DefinePlugin({
ENV: JSON.stringify(config),
globalComponentPrefix: JSON.stringify(globalComponentPrefix),
}),
new CopyWebpackPlugin([
{ from: "node_modules/plain-editor/public/libs", to: "libs" },
])
]
},
chainWebpack(config) {
config.plugins
.delete('prefetch-index')
.delete('preload-index');
config
.plugin('html-index')
.tap((args) => {
args[0].chunksSortMode = 'manual';
return args;
});
config.resolve.alias
.set('@', resolve('src'))
.set('src', resolve('src'))
.set('~', resolve('node_modules'))
.set('plain-design-composition/src/index', resolve('abc'));
// .set('plain-design', resolve('src/packages'))
// .set('plain-design-composition/src/index', resolve('abc'));
// .set('plain-design-composition', resolve('node_modules/plain-design-composition/src/index'));
if (process.env.NODE_ENV === 'development') {
// config.resolve.alias.set('react-dom', 'react-dom/cjs/react-dom.production.min');
}
config.plugins
.delete('prefetch-index')
.delete('preload-index');
},
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。