Advertisement
giwrgos

webpack.config.js

Apr 27th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const webpack = require('webpack');
  2. const path = require('path');
  3. const ExtractTextPlugin = require("extract-text-webpack-plugin");
  4.  
  5. let config = {
  6.     entry: {
  7.         main: [
  8.             './js/theme.js',
  9.             './css/theme.scss'
  10.         ]
  11.     },
  12.     output: {
  13.         path: path.resolve(__dirname, '../assets/js'),
  14.         filename: 'theme.js'
  15.     },
  16.     module: {
  17.         rules: [
  18.             {
  19.                 test: /\.js/,
  20.                 loader: 'babel-loader'
  21.             },
  22.             {
  23.                 test: /\.scss$/,
  24.                 use: ExtractTextPlugin.extract({
  25.                     fallback: 'style-loader',
  26.                     use: [
  27.                         {
  28.                             loader: 'css-loader',
  29.                             options: {
  30.                                 minimize: false
  31.                             }
  32.                         },
  33.                         'postcss-loader',
  34.                         'sass-loader'
  35.                     ]
  36.                 })
  37.             },
  38.             {
  39.                 test: /.(png|woff(2)?|eot|ttf|svg)(\?[a-z0-9=\.]+)?$/,
  40.                 use: [
  41.                     {
  42.                         loader: 'file-loader',
  43.                         options: {
  44.                             name: '../css/[hash].[ext]'
  45.                         }
  46.                     }
  47.                 ]
  48.             },
  49.             {
  50.                 test : /\.css$/,
  51.                 use: ['style-loader', 'css-loader', 'postcss-loader']
  52.             }
  53.         ]
  54.     },
  55.     externals: {
  56.         prestashop: 'prestashop',
  57.         $: '$',
  58.         jquery: 'jQuery'
  59.     },
  60.     plugins: [
  61.         new ExtractTextPlugin(path.join('..', 'css', 'theme.css'))
  62.     ]
  63. };
  64.  
  65. config.plugins.push(
  66.     new webpack.optimize.UglifyJsPlugin({
  67.         sourceMap: false,
  68.         compress: {
  69.             sequences: true,
  70.             conditionals: true,
  71.             booleans: true,
  72.             if_return: true,
  73.             join_vars: true,
  74.             drop_console: true
  75.         },
  76.         output: {
  77.             comments: false
  78.         },
  79.         minimize: false
  80.     })
  81. );
  82.  
  83. module.exports = config;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement