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

96 lines
2.5 KiB
JavaScript
Raw Normal View History

2018-10-22 16:15:45 +00:00
'use strict';
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
2018-10-22 16:15:45 +00:00
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: {
'SpinePlugin': './SpinePlugin.js',
'SpinePlugin.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-both.js'),
loader: 'imports-loader',
options: {
type: 'commonjs',
wrapper: 'window'
}
2018-10-22 16:15:45 +00:00
},
{
test: require.resolve('./src/runtimes/spine-both.js'),
loader: 'exports-loader',
options: {
type: 'commonjs',
exports: 'single spine'
}
2018-10-22 16:15:45 +00:00
}
]
},
resolve: {
alias: {
'Spine': './runtimes/spine-both.js'
2018-10-22 16:15:45 +00:00
},
},
optimization: {
minimizer: [
new TerserPlugin({
2018-10-22 16:15:45 +00:00
include: /\.min\.js$/,
parallel: true,
extractComments: false,
terserOptions: {
format: {
comments: false
},
2018-10-22 16:15:45 +00:00
compress: true,
ie8: false,
ecma: 5,
warnings: false
}
2018-10-22 16:15:45 +00:00
})
]
},
plugins: [
2018-10-24 16:24:32 +00:00
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true)
}),
new RemovePlugin({
before: {
root: './plugins/spine/dist/',
include: [ 'SpinePlugin.js', 'SpinePlugin.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);
});
});
}
}
]
};