Advertisement
Guest User

Untitled

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