Created
August 20, 2020 14:38
-
-
Save arihans/fc6806c8ea4213a854317eebaa6abc89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var webpack = require('webpack'); | |
var HtmlWebpackPlugin = require('html-webpack-plugin'); | |
var BrowserSyncPlugin = require('browser-sync-webpack-plugin'); | |
require('dotenv').config(); | |
// Phaser webpack config | |
var phaserModule = path.join(__dirname, '/node_modules/phaser/'); | |
var phaser = path.join(phaserModule, 'src/phaser.js'); | |
var definePlugin = new webpack.DefinePlugin({ | |
__DEV__: JSON.stringify(JSON.parse(process.env.BUILD_DEV || 'true')), | |
WEBGL_RENDERER: true, | |
CANVAS_RENDERER: true, | |
}); | |
module.exports = { | |
entry: { | |
'game/app': [path.resolve(__dirname, 'public/game/src/main.js')], | |
'game/vendor': ['phaser'], | |
'login/app': path.resolve(__dirname, 'public/login/src/main.js'), | |
}, | |
devtool: 'cheap-source-map', | |
output: { | |
pathinfo: true, | |
path: path.resolve(__dirname, 'dev'), | |
publicPath: './dev/', | |
library: '[name]', | |
libraryTarget: 'umd', | |
filename: '[name].bundle.js', | |
}, | |
watch: true, | |
plugins: [ | |
definePlugin, | |
new HtmlWebpackPlugin({ | |
filename: 'game/index.html', | |
template: path.join(__dirname, '/public/game/src/index.html'), | |
chunks: ['game/vendor', 'game/app'], | |
chunksSortMode: 'manual', | |
}), | |
new HtmlWebpackPlugin({ | |
filename: 'login/index.html', | |
template: path.join(__dirname, '/public/login/src/index.html'), | |
inject: true, | |
chunks: ['login/app'], | |
}), | |
new BrowserSyncPlugin({ | |
host: process.env.IP || 'localhost', | |
port: process.env.PORT || 3000, | |
server: { | |
baseDir: ['./', './dev'], | |
}, | |
}), | |
], | |
module: { | |
rules: [ | |
{ | |
test: /\.js$/, | |
use: ['babel-loader'], | |
include: path.join(__dirname, 'src'), | |
}, | |
{ test: /phaser-split\.js$/, use: ['expose-loader?Phaser'] }, | |
{ test: [/\.vert$/, /\.frag$/], use: 'raw-loader' }, | |
{ | |
test: /\.css$/, | |
use: ['style-loader', 'css-loader'], | |
}, | |
{ | |
test: /\.(png|jpe?g|gif|svg)$/, | |
use: [{ loader: 'url-loader' }], | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment