2018-10-18 13:59:27 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const webpack = require('webpack');
|
2018-10-22 16:15:45 +00:00
|
|
|
const exec = require('child_process').exec;
|
2019-08-08 12:31:52 +00:00
|
|
|
const RemovePlugin = require('remove-files-webpack-plugin');
|
2018-10-18 13:59:27 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2018-10-22 16:15:45 +00:00
|
|
|
mode: 'development',
|
2018-10-18 13:59:27 +00:00
|
|
|
|
|
|
|
context: `${__dirname}/src/`,
|
|
|
|
|
|
|
|
entry: {
|
2019-08-08 12:31:52 +00:00
|
|
|
'SpinePluginDebug': './SpinePlugin.js'
|
2018-10-18 13:59:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
output: {
|
|
|
|
path: `${__dirname}/dist/`,
|
|
|
|
filename: '[name].js',
|
|
|
|
library: 'SpinePlugin',
|
2019-07-31 14:51:14 +00:00
|
|
|
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
|
2018-10-18 13:59:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
performance: { hints: false },
|
|
|
|
|
2018-10-22 16:15:45 +00:00
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
2019-07-16 16:35:15 +00:00
|
|
|
test: require.resolve('./src/runtimes/spine-both.js'),
|
2018-10-22 16:15:45 +00:00
|
|
|
use: 'imports-loader?this=>window'
|
|
|
|
},
|
|
|
|
{
|
2019-07-16 16:35:15 +00:00
|
|
|
test: require.resolve('./src/runtimes/spine-both.js'),
|
2018-10-22 16:15:45 +00:00
|
|
|
use: 'exports-loader?spine'
|
|
|
|
}
|
2018-10-18 13:59:27 +00:00
|
|
|
]
|
|
|
|
},
|
|
|
|
|
2018-10-22 16:15:45 +00:00
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-07-16 16:35:15 +00:00
|
|
|
'Spine': './runtimes/spine-both.js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-10-18 13:59:27 +00:00
|
|
|
plugins: [
|
2018-10-24 11:40:08 +00:00
|
|
|
new webpack.DefinePlugin({
|
|
|
|
"typeof CANVAS_RENDERER": JSON.stringify(true),
|
2018-10-24 13:09:11 +00:00
|
|
|
"typeof WEBGL_RENDERER": JSON.stringify(true)
|
2018-10-24 11:40:08 +00:00
|
|
|
}),
|
2019-08-08 12:31:52 +00:00
|
|
|
new RemovePlugin({
|
|
|
|
before: {
|
|
|
|
root: './plugins/spine/dist/',
|
|
|
|
include: [ 'SpinePluginDebug.js', 'SpinePluginDebug.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'
|
2018-10-18 13:59:27 +00:00
|
|
|
};
|