phaser/plugins/spine/webpack.canvas.dist.config.js

89 lines
2.4 KiB
JavaScript
Raw Normal View History

2018-10-22 16:15:45 +00:00
'use strict';
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const exec = require('child_process').exec;
const RemovePlugin = require('remove-files-webpack-plugin');
2018-10-22 16:15:45 +00:00
module.exports = {
mode: 'production',
context: `${__dirname}/src/`,
entry: {
'SpineCanvasPlugin': './SpinePlugin.js',
'SpineCanvasPlugin.min': './SpinePlugin.js'
2018-10-22 16:15:45 +00:00
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'SpinePlugin',
libraryTarget: 'window'
2018-10-22 16:15:45 +00:00
},
performance: { hints: false },
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'
}
]
},
resolve: {
alias: {
'Spine': './runtimes/spine-canvas.js'
}
2018-10-22 16:15:45 +00:00
},
optimization: {
minimizer: [
new UglifyJSPlugin({
include: /\.min\.js$/,
parallel: true,
sourceMap: false,
uglifyOptions: {
compress: true,
ie8: false,
ecma: 5,
output: {comments: false},
warnings: false
},
warningsFilter: () => false
})
]
},
plugins: [
2018-10-24 16:24:32 +00:00
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(false)
}),
new RemovePlugin({
before: {
before: {
root: './plugins/spine/dist/',
include: [ 'SpineCanvasPlugin.js', 'SpineCanvasPlugin.min.js' ]
}
}
}),
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);
});
});
}
}
]
};