1 Star 0 Fork 7

少年啊/homecheck

forked from OpenHarmony-SIG/homecheck 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
webpack.config.js 2.32 KB
一键复制 编辑 原始数据 按行查看 历史
李雄 提交于 2024-09-13 18:04 . 完善readme文档
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const path = require('path');
const webpack = require('webpack');
module.exports = (env, argv) => {
let outputPath = path.resolve(__dirname, 'dist');
let devtoolModuleFilenameTemplate = '../[resource-path]';
const config = {
name: 'HomeCheck',
target: 'node',
mode:'argv.mode',
entry:{index: './src/index.ts'},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {onlyCompileBundledFiles: true,}
}],
exprContextCritical: false,
},
resolve: {
extensions: ['.ts', '.js', '.json'],
plugins: [new TsconfigPathsPlugin()],
},
output: {
path: outputPath,
filename: '[name].js',
libraryTarget:'commonjs2',
devtoolModuleFilenameTemplate,
},
plugins: [
new webpack.DefinePlugin({MODE_PRODUCTION: JSON.stringify(argv.mode === 'production'),}),
new CleanWebpackPlugin({cleanStaleWebpackAssets: false,}),
],
externals: [
],
};
if (argv.mode === 'production') {
config.plugins.push(
new TerserPlugin({
terserOptions: {sourceMap: true},
extractComments: false,
}),
new webpack.DefinePlugin({MODE_PRODUCTION: JSON.stringify(true),})
);
}
return config;
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/a_boys/homecheck.git
git@gitee.com:a_boys/homecheck.git
a_boys
homecheck
homecheck
master

搜索帮助