dev 环境 不分割代码

This commit is contained in:
Wang Kejun 2022-04-28 12:03:27 +08:00
parent 31bdb54319
commit 05b2a156f6
2 changed files with 13 additions and 3 deletions

View File

@ -20,6 +20,8 @@ const {
} = require('./env'); } = require('./env');
const isDev = NODE_ENV === 'development'; const isDev = NODE_ENV === 'development';
// process.env.OAK_PLATFORM: wechatMp | wechatPublic | web | node
const relativeFileLoader = (ext = '[ext]') => { const relativeFileLoader = (ext = '[ext]') => {
return { return {
loader: 'file-loader', loader: 'file-loader',
@ -107,7 +109,8 @@ module.exports = {
}, },
{ {
test: /\.less$/, test: /\.less$/,
include: /oak-general-business\/wechatMp|oak-general-business\\wechatMp/, include:
/oak-general-business\/wechatMp|oak-general-business\\wechatMp/,
type: 'javascript/auto', type: 'javascript/auto',
use: [ use: [
oakFileLoader('wxss'), oakFileLoader('wxss'),
@ -163,7 +166,8 @@ module.exports = {
}, },
{ {
test: /\.(xml|wxml)$/, test: /\.(xml|wxml)$/,
include: /oak-general-business\/wechatMp|oak-general-business\\wechatMp/, include:
/oak-general-business\/wechatMp|oak-general-business\\wechatMp/,
type: 'javascript/auto', type: 'javascript/auto',
use: [ use: [
oakFileLoader('wxml'), oakFileLoader('wxml'),
@ -181,11 +185,13 @@ module.exports = {
new OakWeChatMpPlugin({ new OakWeChatMpPlugin({
exclude: ['*/weui-miniprogram/*'], exclude: ['*/weui-miniprogram/*'],
include: ['project.config.json', 'sitemap.json'], include: ['project.config.json', 'sitemap.json'],
split: !isDev,
}), }),
new webpack.DefinePlugin({ new webpack.DefinePlugin({
__DEV__: isDev, __DEV__: isDev,
__WECHAT__: true, __WECHAT__: true,
['process.env.NODE_ENV']: JSON.stringify(NODE_ENV), ['process.env.NODE_ENV']: JSON.stringify(NODE_ENV),
['process.env.OAK_PLATFORM']: 'wechatMp',
}), }),
// new MiniCssExtractPlugin({ filename: `[name]${PLATFORM_CONFIG[yamlConfig.platform].style}` }), // new MiniCssExtractPlugin({ filename: `[name]${PLATFORM_CONFIG[yamlConfig.platform].style}` }),
new StylelintPlugin({ new StylelintPlugin({

View File

@ -41,6 +41,7 @@ class OakWeChatMpPlugin {
commonsChunkName: 'commons', commonsChunkName: 'commons',
vendorChunkName: 'vendor', vendorChunkName: 'vendor',
runtimeChunkName: 'runtime', runtimeChunkName: 'runtime',
split: true,
}, },
options options
); );
@ -148,6 +149,7 @@ class OakWeChatMpPlugin {
} }
async setAppEntries(compiler) { async setAppEntries(compiler) {
const { split } = this.options;
this.npmComponents = new Set(); this.npmComponents = new Set();
this.oakPages = new Set(); this.oakPages = new Set();
this.oakComponents = new Set(); this.oakComponents = new Set();
@ -156,7 +158,9 @@ class OakWeChatMpPlugin {
this.addScriptEntry(compiler), this.addScriptEntry(compiler),
this.addAssetsEntries(compiler), this.addAssetsEntries(compiler),
]); ]);
this.applyPlugin(compiler); if (split) {
this.applyPlugin(compiler);
}
} }
// resolve tabbar page compoments // resolve tabbar page compoments