gpt4 book ai didi

javascript - Webpack - 捆绑 js 中未缩小的文件

转载 作者:行者123 更新时间:2023-12-03 02:13:54 27 4
gpt4 key购买 nike

所以,

我是 webpack 的新手,我正在开发一个项目,在该项目中我们只加载一个文件 bundle.js,我知道我可以单独加载文件。

但我想要的是bundle.js中未缩小的文件。目前我正在获取缩小和丑化的文件。

知道如何获得它吗?

我的 webpack.config.js 看起来像:-

var entry,
production,
development,
//copyFilesConfig,
HTMLWebpackPluginConfig,
path = require('path'),
webpack = require('webpack'),
HtmlWebpackPlugin = require('html-webpack-plugin'),
// CopyWebpackPlugin = require('copy-webpack-plugin'),
environment = {
production: true
};

HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
template: __dirname + '/index.html',
filename: 'index.html',
inject: 'body'
});

/*copyFilesConfig = new CopyWebpackPlugin([
{ from: 'dist', to: __dirname + '/build/dist' }
]);*/

development = [HTMLWebpackPluginConfig];

production = [
HTMLWebpackPluginConfig,
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.optimize.UglifyJsPlugin({ mangle: true, sourcemap: false })
];

entry = {
production: [
'./src/index.js'
],
development: [
'webpack-dev-server/client?http://localhost:7000',
'./src/index.js'
]
};

module.exports = {
devtool: environment.production ? null : 'sourcemap',
entry: environment.production ? entry.production : entry.development,
output: {
path: path.join(__dirname, 'build/dist'),
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.js?$/,
loaders: ['babel'],
include: path.join(__dirname, 'src'),
exclude: /node_modules/,
presets: ['react', 'es2015', 'stage-0'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy']
}, {
test: /\.less$/,
loaders: ["style", "css", "less"]
}, {
test: /\.(png|woff|woff2|eot|ttf|svg)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
}]
},
plugins: environment.production ? production : development
}

最佳答案

尝试删除此行:

new webpack.optimize.UglifyJsPlugin({ mangle: true, sourcemap: false })

关于javascript - Webpack - 捆绑 js 中未缩小的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49442179/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com