Guest User

Untitled

a guest
Oct 29th, 2016
1,003
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const autoprefixer = require('autoprefixer');
  4. const precss = require('precss');
  5. const mqpacker = require('css-mqpacker');
  6. const HtmlWebpackPlugin = require('html-webpack-plugin');
  7.  
  8. module.exports = {
  9.   entry: [
  10.     'react-hot-loader/patch',
  11.     'babel-polyfill',
  12.     'whatwg-fetch',
  13.     'webpack-dev-server/client?http://localhost:3000',
  14.     'webpack/hot/only-dev-server',
  15.     './src/index',
  16.   ],
  17.   output: {
  18.     path: path.resolve(process.cwd(), 'dist'),
  19.     publicPath: '/',
  20.     filename: 'app.[hash].js',
  21.   },
  22.   devtool: 'eval',
  23.   module: {
  24.     rules: [{
  25.       test: /\.js$/,
  26.       include: [
  27.         path.resolve(process.cwd(), 'src'),
  28.       ],
  29.       use: [{
  30.         loader: 'babel-loader',
  31.         options: {
  32.           presets: [['es2015', { modules: false }], 'stage-0', 'react'],
  33.           plugins: ['transform-runtime', 'transform-object-rest-spread', 'react-hot-loader/babel'],
  34.         },
  35.       }],
  36.     }, {
  37.       test: /\.css$/,
  38.       include: [
  39.         path.resolve(process.cwd(), 'src'),
  40.       ],
  41.       use: [{
  42.         loader: 'style-loader',
  43.       }, {
  44.         loader: 'css-loader',
  45.         options: {
  46.           modules: true,
  47.           importLoaders: true,
  48.           localIdentName: '[hash:base64:5]',
  49.         },
  50.       }],
  51.     }, {
  52.       test: /\.css$/,
  53.       include: [
  54.         path.resolve(process.cwd(), 'node_modules'),
  55.       ],
  56.       use: [{
  57.         loader: 'style-loader',
  58.       }, {
  59.         loader: 'css-loader',
  60.         options: {
  61.           autoprefixer: false,
  62.         },
  63.       }],
  64.     }, {
  65.       test: /\.(jpe?g|png|gif|svg)$/,
  66.       use: [{
  67.         loader: 'file-loader',
  68.       }, {
  69.         loader: 'image-webpack',
  70.         options: {
  71.           progressive: true,
  72.           optimizationLevel: 7,
  73.           interlaced: false,
  74.           pngquant: {
  75.             quality: '65-90',
  76.             speed: 4,
  77.           },
  78.         },
  79.       }],
  80.     }],
  81.   },
  82.   plugins: [
  83.     new webpack.NamedModulesPlugin(),
  84.     new webpack.HotModuleReplacementPlugin(),
  85.     new webpack.ProgressPlugin(),
  86.     new HtmlWebpackPlugin({
  87.       hash: false,
  88.       template: './index.html',
  89.     }),
  90.     new webpack.LoaderOptionsPlugin({
  91.       test: /\.css$/,
  92.       debug: true,
  93.       options: {
  94.         postcss: [
  95.           precss(),
  96.           autoprefixer({
  97.             browsers: [
  98.               'last 3 version',
  99.               'ie >= 10',
  100.             ],
  101.           }),
  102.           mqpacker(),
  103.         ],
  104.         context: path.join(__dirname, 'src'),
  105.         output: {
  106.           path: path.join(__dirname, 'dist'),
  107.         },
  108.       },
  109.     }),
  110.   ],
  111. };
Advertisement
Add Comment
Please, Sign In to add comment