Guest User

Webpack Wordpress config

a guest
Dec 1st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var path = require('path');
  2. var ExtractTextPlugin = require('extract-text-webpack-plugin');
  3.  
  4. var extractPlugin = new ExtractTextPlugin({
  5.     filename: 'stylesheet.css'
  6. });
  7.  
  8. module.exports = {
  9.     entry: "./lib/js/common.ts",
  10.     output: {
  11.         path: path.resolve(__dirname, './'),
  12.         filename: 'bundle.js',
  13.         publicPath: "/"
  14.     },
  15.     module: {
  16.         rules: [
  17.             {
  18.                 test: /\.ts$/,
  19.                 use: [
  20.                     {
  21.                         loader: 'ts-loader'
  22.                     }
  23.                 ]
  24.             },
  25.             {
  26.                 test: /\.sass$/,
  27.                 use: extractPlugin.extract({
  28.                     use: [
  29.                         {
  30.                             loader: 'css-loader'
  31.                         },
  32.                         {
  33.                             loader: 'postcss-loader',
  34.                             options: {
  35.                                 sourceMap: true
  36.                             }
  37.                         },
  38.                         {
  39.                             loader: 'resolve-url-loader',
  40.                             options: {
  41.                                 sourceMap: true
  42.                             }
  43.                         },
  44.                         {
  45.                             loader: 'sass-loader',
  46.                             options: {
  47.                                 sourceMap: true
  48.                             }
  49.                         }
  50.                     ]
  51.                 })
  52.             },
  53.             {
  54.                 test: /\.(png|jpe?g|svg)$/,
  55.                 use: ['url-loader?limit=100000', 'img-loader']
  56.             },
  57.             {
  58.                 test: /\.(woff|woff2|eot|ttf)$/,
  59.                 use: [
  60.                     {
  61.                         loader: 'url-loader?limit=100000'
  62.                     }
  63.                 ]
  64.             }
  65.         ]
  66.     },
  67.     plugins: [
  68.         extractPlugin
  69.     ]
  70. };
Advertisement
Add Comment
Please, Sign In to add comment