Updated configs

This commit is contained in:
Richard Davey 2018-10-24 17:24:32 +01:00
parent 7ca0edcdfc
commit 769f40e117
6 changed files with 200 additions and 8 deletions

View file

@ -27,11 +27,11 @@
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js", "plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
"plugin.spine": "webpack --config plugins/spine/webpack.config.js", "plugin.spine": "webpack --config plugins/spine/webpack.config.js",
"plugin.spine.dist": "webpack --config plugins/spine/webpack.auto.dist.config.js", "plugin.spine.dist": "webpack --config plugins/spine/webpack.auto.dist.config.js",
"plugin.spine.watch": "webpack --config plugins/spine/webpack.auto.config.js --watch", "plugin.spine.watch": "webpack --config plugins/spine/webpack.auto.config.js --watch --display-modules",
"plugin.spine.canvas.dist": "webpack --config plugins/spine/webpack.canvas.dist.config.js", "plugin.spine.canvas.dist": "webpack --config plugins/spine/webpack.canvas.dist.config.js",
"plugin.spine.canvas.watch": "webpack --config plugins/spine/webpack.canvas.config.js --watch", "plugin.spine.canvas.watch": "webpack --config plugins/spine/webpack.canvas.config.js --watch --display-modules",
"plugin.spine.webgl.dist": "webpack --config plugins/spine/webpack.webgl.dist.config.js", "plugin.spine.webgl.dist": "webpack --config plugins/spine/webpack.webgl.dist.config.js",
"plugin.spine.webgl.watch": "webpack --config plugins/spine/webpack.webgl.config.js --watch", "plugin.spine.webgl.watch": "webpack --config plugins/spine/webpack.webgl.config.js --watch --display-modules",
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"", "lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix", "lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
"sloc": "node-sloc \"./src\" --include-extensions \"js\"", "sloc": "node-sloc \"./src\" --include-extensions \"js\"",

View file

@ -11,8 +11,8 @@ module.exports = {
context: `${__dirname}/src/`, context: `${__dirname}/src/`,
entry: { entry: {
'SpinePlugin': './SpinePlugin.js', 'SpinePlugin': './SpineWebGLPlugin.js',
'SpinePlugin.min': './SpinePlugin.js' 'SpinePlugin.min': './SpineWebGLPlugin.js'
}, },
output: { output: {
@ -52,7 +52,7 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
'SpineCanvas': './runtimes/spine-canvas.js', 'SpineCanvas': './runtimes/spine-canvas.js',
'SpineGL': './runtimes/spine-webgl.js' 'SpineWebGL': './runtimes/spine-webgl.js'
}, },
}, },
@ -75,6 +75,10 @@ module.exports = {
}, },
plugins: [ plugins: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(true)
}),
new CleanWebpackPlugin([ 'dist' ]), new CleanWebpackPlugin([ 'dist' ]),
{ {
apply: (compiler) => { apply: (compiler) => {

View file

@ -50,7 +50,7 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
'SpineCanvas': './runtimes/spine-canvas.js', 'SpineCanvas': './runtimes/spine-canvas.js',
'SpineGL': './runtimes/spine-webgl.js' 'SpineWebGL': './runtimes/spine-webgl.js'
}, },
}, },

View file

@ -0,0 +1,94 @@
'use strict';
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const exec = require('child_process').exec;
module.exports = {
mode: 'production',
context: `${__dirname}/src/`,
entry: {
'SpineCanvasPlugin': './SpineCanvasPlugin.js',
'SpineCanvasPlugin.min': './SpineCanvasPlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'SpineCanvasPlugin',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string
umdNamedDefine: true
},
performance: { hints: false },
module: {
rules: [
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'exports-loader?spine'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
use: 'exports-loader?spine'
}
]
},
resolve: {
alias: {
'SpineCanvas': './runtimes/spine-canvas.js',
'SpineWebGL': './runtimes/spine-webgl.js'
},
},
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: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(true),
"typeof WEBGL_RENDERER": JSON.stringify(false)
}),
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);
});
});
}
}
]
};

View file

@ -50,7 +50,7 @@ module.exports = {
resolve: { resolve: {
alias: { alias: {
'SpineCanvas': './runtimes/spine-canvas.js', 'SpineCanvas': './runtimes/spine-canvas.js',
'SpineGL': './runtimes/spine-webgl.js' 'SpineWebGL': './runtimes/spine-webgl.js'
}, },
}, },

View file

@ -0,0 +1,94 @@
'use strict';
const webpack = require('webpack');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const exec = require('child_process').exec;
module.exports = {
mode: 'production',
context: `${__dirname}/src/`,
entry: {
'SpineWebGLPlugin': './SpineWebGLPlugin.js',
'SpineWebGLPlugin.min': './SpineWebGLPlugin.js'
},
output: {
path: `${__dirname}/dist/`,
filename: '[name].js',
library: 'SpineWebGLPlugin',
libraryTarget: 'umd',
sourceMapFilename: '[file].map',
devtoolModuleFilenameTemplate: 'webpack:///[resource-path]', // string
devtoolFallbackModuleFilenameTemplate: 'webpack:///[resource-path]?[hash]', // string
umdNamedDefine: true
},
performance: { hints: false },
module: {
rules: [
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-canvas.js'),
use: 'exports-loader?spine'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
use: 'imports-loader?this=>window'
},
{
test: require.resolve('./src/runtimes/spine-webgl.js'),
use: 'exports-loader?spine'
}
]
},
resolve: {
alias: {
'SpineCanvas': './runtimes/spine-canvas.js',
'SpineWebGL': './runtimes/spine-webgl.js'
},
},
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: [
new webpack.DefinePlugin({
"typeof CANVAS_RENDERER": JSON.stringify(false),
"typeof WEBGL_RENDERER": JSON.stringify(true)
}),
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);
});
});
}
}
]
};