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



所以,

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

但我想要的是捆绑.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 })

最新更新