2017-01-11 10 views
0

私のベンダーとマニフェストファイルが縮小化されて醜いですが、バンドルはなぜですかない。プラグインの順番ですか? CommonsChunkPluginと何か関係がありますか?Webpack 2.2.0.rc-0は、vendor.jsとmanifest.jsをuglify/minifyしますが、bundle.jsは作成しません。

これは私のUglifyJsPluginコードです:

new webpack.optimize.UglifyJsPlugin({ 
     debug: false, 
     minimize: true, 
     sourceMap: false, 
     output: { 
     comments: false 
     }, 
     compressor: { // eslint-disable-line camelcase 
     warnings: false, 
     unused: true, 
     dead_code: true 
     }, 
     mangle: false 
    }), 

、これが私のWebPACKの設定は、全体のオブジェクトである:

const webpack = require('webpack'); 
 
const conf = require('./gulp.conf'); 
 
const path = require('path'); 
 
const del = require('del'); 
 

 
const CopyWebpackPlugin = require('copy-webpack-plugin'); 
 
const HtmlWebpackPlugin = require('html-webpack-plugin'); 
 
const ExtractTextPlugin = require('extract-text-webpack-plugin'); 
 
const pkg = require('../package.json'); 
 
const autoprefixer = require('autoprefixer'); 
 

 

 
module.exports = { 
 
    entry: { 
 
    bundle: `./${conf.path.src('index')}`, 
 
    vendor: `./src/app/dependencies`, 
 
    }, 
 
    output: { 
 
    path: path.join(process.cwd(), conf.paths.dist), 
 
    filename: '[name].[chunkhash].js' 
 
    }, 
 
    module: { 
 
    rules: [ 
 
     { 
 
     test: /.json$/, 
 
     use: ['json-loader'] 
 
     }, 
 
     { 
 
     test: /.ts$/, 
 
     exclude: /node_modules/, 
 
     enforce: 'pre', 
 
     use: ['tslint-loader'] 
 
     }, 
 
     { 
 
     test: /\.(css|scss)$/, 
 
     use: [ 
 
      'style-loader', 
 
      'css-loader', 
 
      'sass-loader', 
 
      'postcss-loader' 
 
     ] 
 
     }, 
 
     { 
 
     test: /\.js$/, 
 
     exclude: /node_modules/, 
 
     use: [ 
 
      'ng-annotate-loader', 
 
      'babel-loader' 
 
     ] 
 
     }, 
 
     { 
 
     test: /\.ts$/, 
 
     exclude: /node_modules/, 
 
     use: ['ts-loader'] 
 
     }, 
 
     { 
 
     test: /.html$/, 
 
     use: ['html-loader'] 
 
     }, 
 
     { 
 
     test: /\.(jade|pug)$/, 
 
     use: ['pug-html-loader'] 
 
     }, 
 
     { 
 
     test: /\.(eot|woff|woff2|ttf|svg|png|jpg)$/, 
 
     use: ['url-loader?limit=30000&name=[name]-[hash].[ext]'] 
 
     }, 
 
     { 
 
     test: /\.less$/, 
 
     use: ['style-loader','css-loader', 'less-loader'] 
 
     } 
 
    ] 
 
    }, 
 
    plugins: [ 
 
    
 
    new webpack.optimize.UglifyJsPlugin({ 
 
     debug: false, 
 
     minimize: true, 
 
     sourceMap: false, 
 
     output: { 
 
     comments: false 
 
     }, 
 
     compressor: { // eslint-disable-line camelcase 
 
     warnings: false, 
 
     unused: true, 
 
     dead_code: true 
 
     }, 
 
     mangle: false 
 
    }), 
 

 
    new webpack.optimize.CommonsChunkPlugin({ 
 
     names: ['vendor', 'manifest'] 
 
    }), 
 

 
    new webpack.optimize.OccurrenceOrderPlugin(), 
 
    // new webpack.NoErrorsPlugin(), // emits no scripts to browser if there are any errors at all 
 
    new HtmlWebpackPlugin({ 
 
     template: conf.path.src('index.html'), 
 
     inject: true 
 
    }), 
 

 
    new webpack.ContextReplacementPlugin(
 
     /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, 
 
     conf.paths.src 
 
    ), 
 
    new webpack.DefinePlugin({ 
 
     'process.env.NODE_ENV': '"production"' 
 
    }), 
 
    new ExtractTextPlugin('index-[contenthash].css'), 
 
    new webpack.LoaderOptionsPlugin({ 
 
     options: { 
 
     postcss:() => [autoprefixer], 
 
     resolve: {}, 
 
     ts: { 
 
      configFileName: 'tsconfig.json' 
 
     }, 
 
     tslint: { 
 
      configuration: require('../tslint.json') 
 
     } 
 
     } 
 
    }), 
 
    new CopyWebpackPlugin([{ 
 
     from: path.join(conf.paths.src, 'integration', 'embedder', 'embedder.js'), 
 
     to: path.join('integration', 'embedder', 'embedder.js') 
 
    }]) 
 
    ], 
 
    resolve: { 
 
    extensions: [ 
 
     '.webpack.js', 
 
     '.web.js', 
 
     '.js', 
 
     '.ts' 
 
    ] 
 
    } 
 
};

答えて

1

は、答えが判明オプションの設定を追加しましたbabel-loaderにプリセットes2015を含めるようにします。

{ 
    test: /\.js$/, 
    exclude: /node_modules/, 
    use: [ 
     { 
     loader: 'ng-annotate-loader' 
     }, 
     { 
     loader: 'babel-loader', 
     options: { 
      presets: ['es2015'], 
     } 
     } 
    ] 
    }, 

これは、webpack 2でes6コードをuglify/minifyingするために必要です。

関連する問題