webpack.dev.config.js 1.01 KB
const webpack = require('webpack');
const merge = require('webpack-merge');
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const devInfo = require('./dev-info.js');
let baseConfig = require('./webpack.base.config.js');

baseConfig = baseConfig('dev');

// https 环境不支持自动刷新
if (devInfo.publicPath.indexOf('https')) {
    const path = require('path');

    Object.keys(baseConfig.entry).forEach(function(name) {
        baseConfig.entry[name] = [path.join(__dirname, './dev-client.js')].concat(baseConfig.entry[name]);
    });
}

module.exports = merge(baseConfig, {
    mode: 'development',
    output: {
        publicPath: devInfo.publicPath
    },
    devtool: 'source-map',
    performance: {
        maxEntrypointSize: 2048000,
        maxAssetSize: 2048000
    },
    plugins: [
        new ExtractTextPlugin('[name].css'),
        new webpack.HotModuleReplacementPlugin(),
        new FriendlyErrorsPlugin()
    ]
});