'use strict'

const path = require('path')
const webpack = require('webpack')
const config = require('./config')
const utils = require('./utils')

const NODE_ENV = process.env.NODE_ENV || 'production'

module.exports = {
  entry: {
    app: './resources/assets/js/index',
    editor: './resources/assets/js/editor',
  },
  output: {
    path: config[NODE_ENV].assetsRoot,
    publicPath: config[NODE_ENV].assetsPublicPath,
    filename: '[name].js',
  },
  resolve: {
    extensions: ['', '.js', '.vue', '.styl'],
    fallback: [path.join(__dirname, '../../../node_modules')],
    alias: {
      js: path.resolve(__dirname, '../js'),
      Components: path.resolve(__dirname, '../js/Components'),
      vue: 'vue/dist/vue.js',
    },
  },
  resolveLoader: {
    fallback: [path.join(__dirname, '../../../node_modules')],
  },
  module: {
    loaders: [
      {
        test: /\.vue$/,
        loader: 'vue',
      },
      {
        test: /\.js$/,
        loader: 'babel',
        include: path.resolve(__dirname, '../'),
        exclude: /node_modules/,
        query: {
          cacheDirectory: true,
        },
      },
      {
        test: /\.y$/,
        loader: 'raw',
      },
      {
        test: /\.html$/,
        loader: 'vue-html',
      },
      {
        test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
        loader: 'url',
        query: {
          limit: 10000,
          name: utils.assetsPath('img/[name].[hash:7].[ext]'),
        },
      },
      {
        test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
        loader: 'url',
        query: {
          limit: 10000,
          name: utils.assetsPath('fonts/[name].[hash:7].[ext]'),
        },
      },
      {
        test: require.resolve('jquery'),
        loader: 'expose?jQuery!expose?$',
      },
      {
        test: require.resolve(__dirname + '/../js/Parser'),
        loader: 'expose?Parser!babel',
      },
      {
        test: require.resolve('brace'),
        loader: 'expose?ace',
      },
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': config[NODE_ENV].env,
    }),
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery',
    }),
    new webpack.NoErrorsPlugin(),
  ],
  node: {
    fs: 'empty',
  },
  vue: {
    loaders: utils.cssLoaders(),
  },
}

@@ -1786,32 +1786,42 @@
 require.resolve(
+path.join(
 __dirname + '/..
@@ -1817,13 +1817,11 @@
 name
- +
+,
  '
-/
 ../j
@@ -1830,16 +1830,17 @@
 Parser')
+)
 ,%0A      

fix eslint error