Guest User

Untitled

a guest
Jan 27th, 2019
146
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 VueLoaderPlugin = require('vue-loader/lib/plugin');
  4. const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
  5. const HtmlWebpackPlugin = require('html-webpack-plugin');
  6. const CopyWebpackPlugin = require('copy-webpack-plugin');
  7. const ExtractTextPlugin = require("extract-text-webpack-plugin")
  8. module.exports = {
  9.   entry: [
  10.     "./dist/js/index.js",
  11.     './dist/scss/index.scss'
  12.   ],
  13.   output: {
  14.     path: path.resolve(__dirname, './src'),
  15.     filename: "js/app.[hash].js",
  16.     publicPath: './src'
  17.   },
  18.   optimization: {
  19.     splitChunks: {
  20.       chunks: 'all',
  21.     }
  22.   },
  23.   mode: 'production',
  24.   module: {
  25.     rules: [{
  26.         test: /\.vue$/,
  27.         exclude: /node_modules/,
  28.         loader: 'vue-loader'
  29.       },
  30.       {
  31.         test: /\.scss$/,
  32.         use: ExtractTextPlugin.extract({
  33.           fallback: 'style-loader',
  34.           use: [
  35.             'postcss-loader',
  36.             'css-validator-loader',
  37.             {
  38.               loader: 'sass-loader',
  39.               options: {
  40.                 outputStyle: 'expanded'
  41.               }
  42.             }
  43.           ]
  44.         })
  45.       },
  46.       {
  47.         test: /\.js?$/,
  48.         exclude: /node_modules/,
  49.         loader: 'babel-loader'
  50.       },
  51.       {
  52.         test: /\.(png|jpg|gif)$/,
  53.         use: [{
  54.           loader: 'file-loader',
  55.           options: {
  56.             name: '[name].[ext]',
  57.  
  58.           }
  59.         }]
  60.       },
  61.       {
  62.         test: /\.(gif|svg|eot|ttf|woff|woff2)$/,
  63.         loader: 'url-loader',
  64.         options: {
  65.           limit: 10000,
  66.         },
  67.       },
  68.       {
  69.         test: /\.svg$/,
  70.         use: [{
  71.             loader: 'svg-loader'
  72.           },
  73.           {
  74.             loader: 'svg-inline-loader'
  75.           }
  76.         ]
  77.       },
  78.       {
  79.         test: /\.css$/,
  80.         use: ['style-loader', 'postcss-loader']
  81.       }
  82.     ]
  83.   },
  84.   plugins: [
  85.     new ExtractTextPlugin({
  86.       filename: 'css/main.[hash].css',
  87.       allChunks: true
  88.     }),
  89.     new CopyWebpackPlugin([{
  90.         from: './dist/fonts',
  91.         to: '../src/fonts'
  92.       },
  93.       {
  94.         from: './dist/icons',
  95.         to: '../src/icons'
  96.       },
  97.       {
  98.         from: './dist/imgs',
  99.         to: '../src/imgs'
  100.       }
  101.     ]),
  102.     new VueLoaderPlugin(),
  103.     new webpack.NoEmitOnErrorsPlugin(),
  104.     new HtmlWebpackPlugin({
  105.       filename: '../index.html',
  106.       minify: {
  107.         removeComments: true,
  108.         collapseWhitespace: true
  109.       },
  110.       template: './index.template.ejs',
  111.     }),
  112.     new webpack.ProvidePlugin({
  113.       $: "jquery",
  114.       jQuery: "jquery",
  115.       "window.jQuery": "jquery"
  116.     }),
  117.     new UglifyJsPlugin({
  118.       uglifyOptions: {
  119.         ie8: false,
  120.         ecma: 8,
  121.         output: {
  122.           comments: false,
  123.           beautify: false
  124.         }
  125.       }
  126.     })
  127.   ],
  128.   resolve: {
  129.     alias: {
  130.       vue: 'vue/dist/vue.js',
  131.       img: path.resolve(__dirname, 'src/imgs'),
  132.       icon: path.resolve(__dirname, 'src/icons')
  133.     }
  134.   },
  135.   node: {
  136.     module: 'empty',
  137.     fsevents: 'empty',
  138.     net: 'empty',
  139.     tls: 'empty'
  140.   }
  141. };
Advertisement
Add Comment
Please, Sign In to add comment