Guest User

webpack.config.js

a guest
Jan 28th, 2018
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path')
  2.  
  3. // Plugins
  4. const HtmlWebpackPlugin = require('html-webpack-plugin');
  5. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  6.  
  7. module.exports = {
  8.   entry: {
  9.     index: './src/js/index.js'
  10.   },
  11.   output: {
  12.     filename: '[name].bundle.js',
  13.     path: path.join(__dirname, 'dist/js')
  14.   },
  15.   watchOptions: {
  16.     ignored: /node_modules/
  17.   },
  18.   module: {
  19.     rules: [
  20.       {
  21.         test: /\.css$/,
  22.         exclude: /node_modules/,
  23.         use: ExtractTextPlugin.extract({
  24.               fallback: 'style-loader',
  25.               use: [
  26.                 {
  27.                   loader: 'css-loader',
  28.                   options: { importLoaders: 1 }
  29.                 },
  30.                 'postcss-loader'
  31.                 ]
  32.             })
  33.       },
  34.       {
  35.         test: /\.js$/,
  36.         exclude: /node_modules/,
  37.         use: [
  38.           {
  39.             loader: 'babel-loader',
  40.             options: { presets: ['env'] }
  41.           }
  42.         ]
  43.       },
  44.       {
  45.         test: /\.pug$/,
  46.         exclude: /node_modules/,
  47.         use: 'pug-loader'
  48.       }
  49.     ]
  50.   },
  51.   plugins: [
  52.     new ExtractTextPlugin('../css/[name].bundle.css'),
  53.     new HtmlWebpackPlugin({
  54.       filename: '../index.html',
  55.       template: 'src/index.pug',
  56.       chunks: ['index'],
  57.       hash: true
  58.     })
  59.   ]
  60. }
Advertisement
Add Comment
Please, Sign In to add comment