var webpack = require('webpack');
var config = require('./webpack.base.config');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require("extract-text-webpack-plugin");

config.devtool = '#source-map';
// config.output.path = config.extraPath + '../debug';
config.output.publicPath = '/';
config.output.filename = '[name].js';
config.output.chunkFilename = '[name].chunk.js';

config.vue = {
    loaders : {
        css: ExtractTextPlugin.extract(
            "style-loader",
            "css-loader?sourceMap",
            {
                publicPath: 'debug/',
            }
        ),
        less: ExtractTextPlugin.extract(
            'vue-style-loader',
            'css-loader!less-loader'
        ),
        sass: ExtractTextPlugin.extract(
            'vue-style-loader',
            'css-loader!sass-loader'
        )
    }
}

config.plugins = (config.plugins || []).concat([
    new ExtractTextPlugin("[name].css",{ allChunks : true, resolve : ['modules'] }),
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),
    new HtmlWebpackPlugin({
        filename: '../index.html',
        template: './index.ejs',
        inject: true
    }),
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery"
    })
]);

config.devServer = {
    contentBase: './dist',
    host: '0.0.0.0',
    port: 1028,
    hot: true,
    inline: true,
    // useLocalIp: true,
    compress: true,
    disableHostCheck: true,
    historyApiFallback: true
}

module.exports = config;
