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

83 lines
2.3 KiB
JavaScript
Raw Permalink Normal View History

'use strict';
const webpack = require('webpack');
2018-10-22 16:15:45 +00:00
const exec = require('child_process').exec;
const RemovePlugin = require('remove-files-webpack-plugin');
module.exports = {
2018-10-22 16:15:45 +00:00
mode: 'development',
context: `${__dirname}/src/`,
entry: {
'SpineWebGLPluginDebug': './SpinePlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
2019-07-22 16:28:11 +00:00
library: 'SpinePlugin',
libraryTarget: 'window',
2018-10-22 16:15:45 +00:00
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-webgl.js'),
loader: 'imports-loader',
options: {
type: 'commonjs',
wrapper: 'window'
}
2018-10-22 16:15:45 +00:00
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
loader: 'exports-loader',
options: {
type: 'commonjs',
exports: 'single spine'
}
2018-10-22 16:15:45 +00:00
}
]
},
2018-10-22 16:15:45 +00:00
resolve: {
alias: {
2019-07-22 16:28:11 +00:00
'Spine': './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)
}),
new RemovePlugin({
before: {
before: {
root: './plugins/spine/dist/',
include: [ 'SpineWebGLPluginDebug.js', 'SpineWebGLPluginDebug.js.map' ]
}
}
}),
2018-10-22 16:15:45 +00:00
{
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'
};