簡體   English   中英

Webpack-捆綁包JS中未縮小的文件

[英]Webpack - unminified files in bundle js

所以,

我是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 })

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM