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

const urlDomain = "http://pub.dwstatic.com/";
const urlPath = "p/fhvideo/";

config.output.path = config.extraPath + '/build';
config.output.publicPath = `${urlDomain}${urlPath}build/`;
config.output.filename = '[name].js?[hash]';
config.output.chunkFilename = '[name].chunk.js?[hash]';

config.vue = {
    loaders : {
        css: ExtractTextPlugin.extract(
            "style-loader",
            "css-loader?sourceMap",
            {
                publicPath: 'build/',
            }
        ),
        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?[hash]",{ allChunks : true, resolve : ['modules'] }),
    new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js?[hash]'),
    new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: '"production"'
        }
    }),
    new webpack.optimize.UglifyJsPlugin({
        compress: {
            warnings: false
        }
    }),
    new HtmlWebpackPlugin({
        filename: '../index.html',
        template: './index.ejs',
        inject: false
    }),
    new webpack.ProvidePlugin({
        $: "jquery",
        jQuery: "jquery",
        "window.jQuery": "jquery"
    })
]);

module.exports = config;
