import path from 'path'
import webpack from 'webpack'
import DashboardPlugin from 'webpack-dashboard/plugin'
import webpackBaseConfig from './webpack.config.base.babel'
import config from '../config'

const projectSource = path.resolve(process.cwd(), './src')

export default {
  ...webpackBaseConfig,

  cache: true,
  devtool: 'eval',

  entry: [
    'react-hot-loader/patch',
    `webpack-hot-middleware/client?path=http://${config.host}:${config.wdsPort}/__webpack_hmr`,
    path.join(process.cwd(), 'src/app/styles/global/app.scss'),
    path.join(process.cwd(), '.noxt/app/app.dev.js'),
  ],

  output: {
    ...webpackBaseConfig.output,
    publicPath: `http://${config.host}:${config.wdsPort}/build/`,
    filename: '[name].js',
    chunkFilename: '[name].chunk.js',
  },

  module: {
    ...webpackBaseConfig.module,
    rules: [
      ...webpackBaseConfig.module.rules,
      {
        test: /\.js$/,
        include: projectSource,
        loader: 'babel-loader',
        options: {
          cacheDirectory: true,
        },
      },
      {
        test: /\.css$/,
        include: projectSource,
        use: [
          'style-loader',
          'css-loader',
        ],
      },
      {
        test: /\.scss$/,
        include: projectSource,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: {
              module: true,
              importLoaders: 1,
              sourceMap: true,
              localIdentName: '[name]__[local]___[hash:base64:5]',
            },
          },
          {
            loader: 'sass-loader',
            options: {
              sourceMap: true,
              includePaths: [path.join(process.cwd(), 'src/app/styles')],
            },
          },
        ],
      },
      {
        test: /\.(jpg|png|gif)$/,
        loader: 'file-loader',
      },
    ],
  },

  plugins: [
    ...webpackBaseConfig.plugins,
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        NODE_ENV: JSON.stringify('development'),
        BROWSER: JSON.stringify(true),
      },
    }),
    new DashboardPlugin(),
    // new webpack.DllReferencePlugin({
    //   context: process.cwd(),
    //   manifest: require('../../static/build/react-manifest.json'),
    // }),
  ],
}

@@ -198,68 +198,8 @@
 g'%0A%0A
-const projectSource = path.resolve(process.cwd(), './src')%0A%0A
 expo
@@ -848,40 +848,8 @@
 $/,%0A
-        include: projectSource,%0A
     
@@ -868,32 +868,32 @@
 'babel-loader',%0A
+
         options:
@@ -983,40 +983,8 @@
 $/,%0A
-        include: projectSource,%0A
     
@@ -1064,32 +1064,32 @@
      %7D,%0A      %7B%0A
+
         test: /%5C
@@ -1101,40 +1101,8 @@
 $/,%0A
-        include: projectSource,%0A
     

fix bug about dev-hmr task