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.publicPath = '/';
config.output.filename = '[name].js';
config.output.chunkFilename = '[name].chunk.js';

config.vue = {
    loaders : {
        css: ExtractTextPlugin.extract(
            "style-loader",
            "css-loader?sourceMap",
            {
                publicPath: '/',
            }
        ),
        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: false
    }),
    new HtmlWebpackPlugin({
        filename: '../download.html',
        template: './download.ejs',
        inject: false
    }),
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery"
    })
]);

module.exports = config;
