Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const merge = require('webpack-merge');
  2. const webpack = require('webpack');
  3. const { SRC, DIST, ASSETS } = require('./paths');
  4. const LiveReloadPlugin = require('webpack-livereload-plugin');
  5. const HtmlWebpackPlugin = require('html-webpack-plugin');
  6. const path = require('path');
  7.  
  8. module.exports = {
  9.   entry: {
  10.     main: [
  11.       path.resolve(SRC, './index.js')
  12.     ],
  13.     vendor: [
  14.       path.resolve(SRC, './js/vendor/index.js')
  15.     ]
  16.   },
  17.   output: {
  18.     path: DIST,
  19.     filename: 'js/[name].js',
  20.     publicPath: ASSETS
  21.   },
  22.  
  23.   module: {
  24.     rules: [
  25.       {
  26.         test: /\.(scss|css)$/,
  27.         use: [
  28.           {
  29.             loader: "style-loader" // creates style nodes from JS strings
  30.           },
  31.           {loader: 'css-loader'},
  32.           {loader: 'sass-loader'}
  33.         ]
  34.       },
  35.       {
  36.         test: /\.(html)$/,
  37.         use: {
  38.           loader: 'html-loader',
  39.           options: {
  40.             attrs: [':data-src']
  41.           }
  42.         }
  43.       },
  44.       {
  45.         test: /\.(gif|png|jpe?g|svg)$/i,
  46.         use: [{
  47.           loader: 'file-loader',
  48.           options: {
  49.             name: 'images/[name].[ext]'
  50.           }
  51.         }],
  52.       },
  53.       {
  54.         test: /\.js$/,
  55.         // exclude: /(node_modules|vendor)/,
  56.         use: {
  57.           loader: 'babel-loader',
  58.           // options: {
  59.           //   ...JSON.parse(fs.readFileSync(path.resolve(__dirname, '../.babelrc'))),
  60.           // }
  61.         }
  62.       },
  63.       {
  64.         test: /\.(woff(2)?|ttf|eot|svg)(\?v=\d+\.\d+\.\d+)?$/,
  65.         exclude: [/images/],
  66.         use: [{
  67.           loader: 'file-loader',
  68.           options: {
  69.             name: '[name].[ext]',
  70.             outputPath: 'fonts/'
  71.           }
  72.         }]
  73.       },
  74.       {
  75.         test: /\.pdf$/,
  76.         use: [{
  77.           loader: 'file-loader',
  78.           options: {
  79.             name: '[name].[ext]',
  80.             outputPath: 'doc/'
  81.           }
  82.         }]
  83.       }
  84.     ]
  85.   },
  86.   mode: 'development',
  87.   watch: true,
  88.   devServer: {
  89.     contentBase: path.join(__dirname, "../dist/"),
  90.     port: 9005
  91.   },
  92.   plugins: [
  93.     new LiveReloadPlugin(),
  94.     new HtmlWebpackPlugin({
  95.       template: './src/index.html',
  96.       filename: 'index.html',
  97.       minify: true
  98.     }),
  99.     // new OptimizeCSSAssetsPlugin({}),
  100.     // new MiniCssExtractPlugin({
  101.     //   filename: 'styles.css'
  102.     // }),
  103.     new webpack.ProvidePlugin({
  104.       $: "jquery",
  105.       jQuery: "jquery",
  106.       "window.jQuery": "jquery"
  107.     })
  108.   ]
  109. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement