const path = require('path')
const webpack = require('webpack')
const config = require('../config')
const utils = require('./utils')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const HtmlPlugin = require('html-webpack-plugin')
const env = config.build.env

const webpackConfig = merge(baseWebpackConfig, {
  entry: './docs-src/index.js',
  output: {
    filename: 'docs.bundle.js',
    path: config.docs.dist
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': env
    }),
    new webpack.BannerPlugin({
      banner: config.banner,
      raw: true,
      entryOnly: true
    }),
    new ExtractTextPlugin({
      filename: 'docs.bundle.css'
    }),
    new HtmlPlugin({
      filename: 'index.html',
      template: path.join(config.docs.src, 'index.html'),
      inject: true,
      minifiy: {
        removeComments: true,
        collapse: true,
        removeAttributQuotes: true
      },
      chunkSortMode: 'dependency'
    })
  ]
})

module.exports = webpackConfig
