Guest User

webpack.config.js

a guest
Feb 4th, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path')
  2. const fs = require('fs')
  3.  
  4. // Plugins
  5. const webpack = require('webpack')
  6. const HtmlWebpackPlugin = require('html-webpack-plugin')
  7. const ExtractTextPlugin = require('extract-text-webpack-plugin')
  8.  
  9. module.exports = {
  10.   entry: {
  11.     'index': './src/pages/index/index.js',
  12.     'contact': './src/pages/contact/index.js'
  13.   },
  14.   output: {
  15.     filename: 'pages/[name]/index.bundle.js',
  16.     path: path.join(__dirname, 'dist/')
  17.   },
  18.   watchOptions: {
  19.     ignored: /node_modules/
  20.   },
  21.   module: {
  22.     rules: [
  23.       {
  24.         test: /\.css$/,
  25.         exclude: /node_modules/,
  26.         use: ExtractTextPlugin.extract({
  27.           fallback: 'style-loader',
  28.           use: [
  29.             'css-loader',
  30.             {
  31.               loader: 'postcss-loader',
  32.               options: {
  33.                 plugins: () => [
  34.                   require('autoprefixer')
  35.                 ]
  36.               }
  37.             }
  38.           ]
  39.         })
  40.       },
  41.       {
  42.         test: /\.pug$/,
  43.         exclude: /node_modules/,
  44.         use: [
  45.           'pug-loader'
  46.         ]
  47.       },
  48.       {
  49.         test: /\.vue$/,
  50.         exclude: /node_modules/,
  51.         use: [
  52.           'vue-loader'
  53.         ]
  54.       },
  55.       {
  56.         enforce: 'post',
  57.         test: /\.js$/,
  58.         exclude: /node_modules/,
  59.         use: [
  60.           {
  61.             loader: 'babel-loader',
  62.             options: {presets: ['env']}
  63.           }
  64.         ]
  65.       }
  66.     ]
  67.   },
  68.   plugins: [
  69.     new ExtractTextPlugin('/css/[name].bundle.css'),
  70.     new webpack.optimize.CommonsChunkPlugin({
  71.       name: 'common',
  72.     }),
  73.     new HtmlWebpackPlugin({
  74.       filename: 'index.html',
  75.       template: 'src/pages/index/index.pug',
  76.       chunks: ['index'],
  77.       hash: true
  78.     })
  79.   ]
  80. }
Advertisement
Add Comment
Please, Sign In to add comment