var path = require('path')
var cssLoaders = require('./css-loaders')
var projectRoot = path.resolve(__dirname, '../')

module.exports = {
  entry: {
    app: './src/main.js',
    'android-app': './src/android.js'
  },
  output: {
    path: path.resolve(__dirname, '../dist/safecheck'),
    publicPath: 'safecheck/',
    filename: '[name].js'
  },
  resolve: {
    extensions: ['', '.js', '.vue'],
    fallback: [path.join(__dirname, '../node_modules')],
    alias: {
      'src': path.resolve(__dirname, '../src'),
      'vue-strap': path.resolve(__dirname, '../node_modules/vue-client/src/vue-strap')
    }
  },
  resolveLoader: {
    fallback: [path.join(__dirname, '../node_modules')]
  },
  externals: {
    'AMap': 'AMap'
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue'
      },
      {
        test: /\.js$/,
        loader: 'babel',
        include: [
          `${projectRoot}\\src`,
          `${projectRoot}\\build`,
          `${projectRoot}\\examples`,
          `${projectRoot}\\test`,
          `${projectRoot}\\node_modules\\vue-client\\src`,
          `${projectRoot}\\node_modules\\vue-strap\\src`,
          `${projectRoot}\\node_modules\\telephone-clients\\src`,
          `${projectRoot}\\node_modules\\system-clients\\src`,
          `${projectRoot}\\node_modules\\system-phone\\src`,
          `${projectRoot}\\node_modules\\ol`
        ]
      },
      {
        test: /\.json$/,
        loader: 'json'
      },
      {
        test: /\.html$/,
        loader: 'vue-html'
      },
      {
        test: /\.less$/,
        loader: 'style!css!less'
      },
      {
        test: /\.(png|jpg|gif|svg|woff2?|eot|ttf)(\?.*)?$/,
        loader: 'url',
        query: {
          limit: 10000,
          name: '[name].[ext]?[hash:7]'
        }
      },
      {
        test: /\.css$/,
        loader: 'style!css'
        }
    ]
  },

  vue: {
    loaders: cssLoaders({
      sourceMap: false,
      extract: false
    })
  },
  plugins: [],
  eslint: {
    formatter: require('eslint-friendly-formatter')
  }
}
