Last active
October 26, 2017 09:49
-
-
Save oal/898df82fa64e54dd16d0 to your computer and use it in GitHub Desktop.
Webpack config for Pixi.js using Babel.
This file contains hidden or 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
'use strict'; | |
var webpack = require('webpack'); | |
var path = require('path'); | |
module.exports = { | |
entry: './src/game.js', | |
output: { | |
filename: 'build/game.js' | |
}, | |
node: { | |
fs: 'empty' | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.json$/, | |
include: path.join(__dirname, 'node_modules', 'pixi.js'), | |
loader: 'json', | |
}, | |
{ | |
test: /\.js$/, | |
exclude: path.join(__dirname, 'node_modules'), | |
loader: 'babel' | |
} | |
] | |
} | |
}; |
Awesome 💃
This will actually just create an empty module for fs. Once any function is called that uses fs
(ex: AsciiFilter.js#L25), the fs
module will be empty and you will hit an error.
To avoid this, you can dump the file contents that would normally be loaded from fs
into a string inline within the js file. This can be done using a in a postLoader
, brfs
(browserify-fs), and transform-loader
.
npm install brfs
npm install transform-loader
then add this to the webpack config:
postLoaders: [
{
test: /\.js$/,
loader: 'transform/cacheable?brfs',
include: /node_modules\/pixi\.js/
}
]
This is the most direct and simple example of configuring webpack with PIXI that I found.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this!