所以,
我是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
}
答案 0 :(得分:1)
尝试删除此行:
new webpack.optimize.UglifyJsPlugin({ mangle: true, sourcemap: false })