Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
62
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 HTMLWebpackPlugin = require('html-webpack-plugin');
  4. const { CleanWebpackPlugin } = require('clean-webpack-plugin');
  5.  
  6. module.exports = {
  7.   target: 'web',
  8.   mode: 'development',
  9.   entry: {
  10.     app: ['./src/main.js'],
  11.     vendor: ['phaser'],
  12.   },
  13.   output: {
  14.     path: path.resolve(__dirname, './build'),
  15.     filename: '[name]-bundle.js',
  16.   },
  17.   module: {
  18.     rules: [
  19.       {
  20.         // Babel for ES6
  21.         test: /\.(m?js|ts)x?$/,
  22.         exclude: /(node_modules|bower_components)/,
  23.         use: { loader: 'babel-loader' },
  24.       },
  25.       {
  26.         // CSS and styling
  27.         test: /\.css$/,
  28.         use: ['style-loader', 'css-loader'],
  29.       },
  30.       {
  31.         // CSS and styling
  32.         test: /\.scss$/,
  33.         use: ['style-loader', 'css-loader', 'sass-loader'],
  34.       },
  35.       {
  36.         // Images
  37.         test: /\.(png|jpe?g|gif|jpg)$/,
  38.         use: [
  39.           {
  40.             loader: 'file-loader',
  41.             options: {
  42.               name: '[path][name].[ext]',
  43.             },
  44.           },
  45.         ],
  46.       },
  47.     ],
  48.   },
  49.   devServer: {
  50.     host: 'localhost',
  51.     publicPath: '/',
  52.     contentBase: path.join(__dirname, 'src'),
  53.     watchContentBase: true,
  54.     compress: true,
  55.     port: 3000,
  56.   },
  57.   plugins: [
  58.     // Cleans build folder
  59.     new CleanWebpackPlugin(),
  60.     // Inserts bundled js into template
  61.     new HTMLWebpackPlugin({
  62.       title: 'Tile World',
  63.       template: './public/index.html',
  64.     }),
  65.     new webpack.DefinePlugin({
  66.       CANVAS_RENDERER: JSON.stringify(true),
  67.       WEBGL_RENDERER: JSON.stringify(true),
  68.     }),
  69.   ],
  70.   optimization: {
  71.     splitChunks: {
  72.       name: 'vendor',
  73.       chunks: 'all',
  74.     },
  75.     minimize: true,
  76.   },
  77.   devtool: 'inline-source-map',
  78. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement