如何在使用webpack捆绑后减小文件大小?

时间:2017-05-02 16:01:55

标签: javascript reactjs webpack webpack-dev-server

我是新手使用webpack,在捆绑之后我的文件大小超过500kb只有以下内容:

import React, { Component } from 'react';
class App extends Component {
return(
      <div>
        <h1>Hello World</h1>
      </div>
    );
}

ReactDOM.render( <App />, document.getElementById('main') );

我说的不正常。我的webpack配置:

module.exports = {

    entry: path.resolve(__dirname, 'src') + '/app/index.jsx',
    output: {
        path: path.resolve(__dirname, 'dist') + '/bundled',
        filename: 'bundle.js',
        publicPath: '/bundled/'
    },
    module: {
        loaders: [
            {
                test: /\.jsx$/,
                include: path.resolve(__dirname, 'src'),
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015'],
                    plugins: ['transform-class-properties']
                }
            }
        ]
    }
};

我有什么遗漏导致这个更大的文件大小?

0 个答案:

没有答案