title: Webpack with babel-loader not emitting valid es5
body: <p>I have a webpack config that is based off <a href="https://github.com/vuejs-templates/webpack-simple/blob/master/template/webpack.config.js" rel="nofollow noreferrer">https://github.com/vuejs-templates/webpack-simple/blob/master/template/webpack.config.js</a>
  It uses vue-loader and babel-loader. The issue is I cannot get it to generate ES5 code so that it will work in the most broad range of clients. </p>
  
  <p>If I use the ES2015 preset, <code>webpack.optimize.UglifyJsPlugin</code> fails to minify the output because Uglify can only handle ES5 (not counting the harmony branch). The errors are similar to: <code>Unexpected token: punc (()</code> and occur in multiple files.</p>
  
  <p>I can work around this by using <code>babili-webpack-plugin</code> which will minify the ES6 code but is very slow. However, when I deploy this code, I see errors being reported back saying <code>Block-scoped declarations (let, const, function, class) not yet supported outside strict mode</code> so I know they are older clients choking on ES6 code. </p>
  
  <p>How can I get proper ES5 code output from <strong>babel-loader</strong>? I have tried multiple presets, with or without the <code>transform-runtime</code> plugin. Config below:</p>
  
  <pre><code>const webpack = require('webpack');
  const globEntries = require('webpack-glob-entries');
  const _ = require('lodash');
  const path = require('path');
  const BabiliPlugin = require("babili-webpack-plugin");
  
  const env = process.env.NODE_ENV;
  
  let entries;
  if (env === 'production') {
    entries = globEntries('./src/**/vue/*.js');
  } else {
    entries = _.mapValues(globEntries('./src/**/vue/*.js'), entry =&gt; [entry, 'webpack-hot-middleware/client?reload=true']);
  }
  
  module.exports = {
    entry: entries,
    output: {
      path: '/', ///no real path is required, just pass "/"
      publicPath: '/vue',
      filename: '[name].js',
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader',
          options: {
            loaders: {
              scss: 'vue-style-loader!css-loader!sass-loader',
              sass: 'vue-style-loader!css-loader!sass-loader?indentedSyntax',
            },
            // other vue-loader options go here
          },
        },
        {
          test: /\.js$/,
          exclude: /node_modules/,
          use: {
            loader: 'babel-loader',
            query: {
              presets: ['es2015'],
              plugins: ['transform-runtime'],
            },
          },
        },
        {
          test: /\.(png|jpg|gif|svg)$/,
          loader: 'file-loader',
          options: {
            name: '[name].[ext]?[hash]',
          },
        },
      ],
    },
    resolve: {
      alias: {
        vue$: 'vue/dist/vue.esm.js',
      },
    },
    plugins: [
      new webpack.HotModuleReplacementPlugin(), // Enable HMR
      new webpack.NoEmitOnErrorsPlugin(),
    ],
    performance: {
      hints: false,
    },
    devtool: '#eval-source-map',
  };
  
  if (env === 'staging' || env === 'production') {
    //module.exports.devtool = env === 'staging' ? '#source-map' : false;
    module.exports.devtool = '#source-map';
    module.exports.output.path = path.resolve(__dirname, './src/v1/parse/cloud/public/vue');
    // http://vue-loader.vuejs.org/en/workflow/production.html
    module.exports.plugins = (module.exports.plugins || []).concat([
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: `"${env}"`,
        },
      }),
      new webpack.optimize.UglifyJsPlugin({
        sourceMap: true,
        compress: {
          warnings: false,
        },
      }),
      // new BabiliPlugin(),
      new webpack.LoaderOptionsPlugin({
        minimize: true,
      }),
    ]);
  }
  </code></pre>