求解,为什么我在webpack用babel-loader@8.0.6打包有一堆不认识的依赖?
如下图,红色部分是我的代码,为了防止额外的依赖,我从网上下载的./crypto-js.min.js
引入,还是有很多没用的依赖,不知道是怎么打包进来的
这是依赖
package.json
这是我的webpack配置
const webpack = require('webpack');
const path = require('path');
const { getIPAdress, findPara, assetsPath } = require('./utils/util');
const rules = require('./rules/dev');
// const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpackMerge = require('webpack-merge');
const pcConfig = require('./pc.config');
const h5Config = require('./h5.config');
const buildType = findPara('devtype');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const JavaScriptObfuscator = require('webpack-obfuscator');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = {
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, '../dist'),
filename: assetsPath('[name].[hash:8].js'),
libraryTarget: 'umd',
library: 'gp',
},
module: {
rules: [
{
test: /\.js$/,
use: ['babel-loader'],
include: [
path.resolve('src'),
],
},
{
test: /\.tsx?$/,
use: [{
loader: JavaScriptObfuscator.loader,
options: {
rotateStringArray: true,
deadCodeInjection: true,
unicodeEscapeSequence: true,
}
},
'ts-loader'
],
include: [path.resolve('src')]
}
]
},
plugins: [
new webpack.HashedModuleIdsPlugin(),
// enable scope hoisting
new webpack.optimize.ModuleConcatenationPlugin(),
new CleanWebpackPlugin(),
new BundleAnalyzerPlugin(),
],
resolve: {
alias: {
'@': path.join(__dirname, '..'),
'@src': path.join(__dirname, '..', 'src')
}
},
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好像是因为这个
目前处理把这行代码删除,删前721kb,删后79kb..