phaser/plugins/spine/webpack.webgl.config.js

77 lines
2.2 KiB
JavaScript
Raw Normal View History

'use strict';
const webpack = require('webpack');
const CleanWebpackPlugin = require('clean-webpack-plugin');
2018-10-22 16:15:45 +00:00
const exec = require('child_process').exec;
module.exports = {
2018-10-22 16:15:45 +00:00
mode: 'development',
context: `${__dirname}/src/`,
entry: {
'SpineWebGLPlugin': './SpineWebGLPlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'SpineWebGLPlugin',
2018-10-22 16:15:45 +00:00
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string
umdNamedDefine: true
},
performance: { hints: false },
2018-10-22 16:15:45 +00:00
module: {
rules: [
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
2018-10-22 16:15:45 +00:00
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
2018-10-22 16:15:45 +00:00
use: 'exports-loader?spine'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
2018-10-22 16:15:45 +00:00
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
2018-10-22 16:15:45 +00:00
use: 'exports-loader?spine'
}
]
},
2018-10-22 16:15:45 +00:00
resolve: {
alias: {
'SpineCanvas': './runtimes/spine-canvas.js',
2018-10-24 16:24:32 +00:00
'SpineWebGL': './runtimes/spine-webgl.js'
2018-10-22 16:15:45 +00:00
},
},
plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(false),
"typeof WEBGL_RENDERER": JSON.stringify(true)
}),
2018-10-22 16:15:45 +00:00
new CleanWebpackPlugin([ 'dist' ]),
{
apply: (compiler) => {
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
exec('node plugins/spine/copy-to-examples.js', (err, stdout, stderr) => {
if (stdout) process.stdout.write(stdout);
if (stderr) process.stderr.write(stderr);
});
});
}
}
],
devtool: 'source-map'
};