text: 'use strict'
  const path = require('path')
  const ExtractTextPlugin = require('extract-text-webpack-plugin')
  const isProduction = process.env.NODE_ENV === 'production'
  
  function resolve (dir) {
    return path.join(__dirname, '..', dir)
  }
  
  module.exports = {
    context: path.resolve(__dirname, '../'),
    entry: {
      app: './src/entry-app.js',
      sw: './src/entry-sw.js'
    },
    output: {
      path: resolve('public'),
      filename: '[name].js'
    },
    resolve: {
      extensions: ['.js', '.vue', '.json'],
      alias: {
        vue: 'vue/dist/vue.esm.js',
        '@': resolve('src')
      }
    },
    module: {
      rules: [
        {
          test: /\.vue$/,
          loader: 'vue-loader',
          options: {
            extractCSS: isProduction,
            cssSourceMap: true
          }
        },
        {
          test: /\.js$/,
          loader: 'babel-loader',
          exclude: /node_modules/
        },
        {
          test: /\.css$/,
          use: isProduction
            ? ExtractTextPlugin.extract({
              use: 'css-loader',
              fallback: 'vue-style-loader'
            })
            : ['vue-style-loader', 'css-loader']
        },
        {
          test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
          loader: 'url-loader',
          options: {
            limit: 2048,
            name: 'img/[name].[hash:7].[ext]'
          }
        },
        {
          test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
          loader: 'url-loader',
          options: {
            limit: 2048,
            name: 'media/[name].[hash:7].[ext]'
          }
        },
        {
          test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
          loader: 'url-loader',
          options: {
            limit: 2048,
            name: 'fonts/[name].[hash:7].[ext]'
          }
        }
      ]
    }
  }
  