Created
August 5, 2018 02:51
-
-
Save Majirefy/f8975e45c62520ef1fd967aa0408d280 to your computer and use it in GitHub Desktop.
Phaser-CE Webpack config.
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
const path = require('path'); | |
const webpack = require('webpack'); | |
const CopyWebpackPlugin = require('copy-webpack-plugin'); | |
const phaserModule = path.join(__dirname, '/node_modules/phaser-ce/'); | |
const phaser = path.join(phaserModule, 'build/custom/phaser-split.js'); | |
const pixi = path.join(phaserModule, 'build/custom/pixi.js'); | |
const p2 = path.join(phaserModule, 'build/custom/p2.js'); | |
module.exports = { | |
mode: "development", | |
devtool: "inline-source-map", | |
resolve: { | |
extensions: [".ts", ".tsx", ".js"], | |
alias: { | |
'phaser': phaser, | |
'pixi': pixi, | |
'p2': p2 | |
} | |
}, | |
entry: { | |
vendor: ['pixi', 'p2', 'phaser'], | |
app: "./src/index.ts" | |
}, | |
output: { | |
path: path.resolve(__dirname, 'dist'), | |
filename: "[name].js", | |
chunkFilename: "[name].js" | |
}, | |
module: { | |
rules: [ | |
{ test: /pixi\.js/, use: ['expose-loader?PIXI'] }, | |
{ test: /p2\.js/, use: ['expose-loader?p2'] }, | |
{ test: /phaser-split\.js/, use: ['expose-loader?Phaser'] }, | |
{ test: /\.tsx?$/, loader: "ts-loader" } | |
] | |
}, | |
plugins: [ | |
new CopyWebpackPlugin([ | |
{ | |
from: path.resolve(__dirname, 'index.html'), | |
to: path.resolve(__dirname, 'dist') | |
}, | |
{ | |
from: path.resolve(__dirname, 'assets', '**', '*'), | |
to: path.resolve(__dirname, 'dist') | |
}, | |
{ | |
from: path.resolve(__dirname + '/node_modules/webfontloader/', 'webfontloader.js'), | |
to: path.resolve(__dirname, 'dist') | |
} | |
]), | |
new webpack.DefinePlugin({ | |
'typeof CANVAS_RENDERER': JSON.stringify(true), | |
'typeof WEBGL_RENDERER': JSON.stringify(true) | |
}) | |
], | |
optimization: { | |
splitChunks: { | |
name: false, | |
cacheGroups: { | |
vendor: { | |
chunks: "initial", | |
name: "vendor", | |
test: "vendor", | |
enforce: true | |
} | |
} | |
} | |
}, | |
devServer: { | |
contentBase: path.resolve(__dirname, 'dist'), | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment