mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
9b04392211
* Move Node output: /dist.js => /dist/node/scratch-vm.js * Move web output: /vm{.js,.min.js} => /dist/web/scratch-vm{.js,.min.js} * Update build output references in package.json and the playground's index.html * Move the VirtualMachine class out of index.js into its own file, referenced by index.js. The VirtualMachine class is otherwise unchanged. * Add .gitattributes rules for new file types which were added to this repository without specifying their text/binary attributes * Turn on source maps in webpack and add corresponding .gitignore rule
125 lines
3.5 KiB
JavaScript
125 lines
3.5 KiB
JavaScript
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
var defaultsDeep = require('lodash.defaultsdeep');
|
|
var path = require('path');
|
|
var webpack = require('webpack');
|
|
|
|
var base = {
|
|
devServer: {
|
|
contentBase: path.resolve(__dirname, 'playground'),
|
|
host: '0.0.0.0',
|
|
port: process.env.PORT || 8073
|
|
},
|
|
devtool: 'source-map',
|
|
module: {
|
|
loaders: [
|
|
{
|
|
test: /\.json$/,
|
|
loader: 'json-loader'
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
include: /\.min\.js$/,
|
|
minimize: true,
|
|
compress: {
|
|
warnings: false
|
|
}
|
|
})
|
|
]
|
|
};
|
|
|
|
module.exports = [
|
|
// Web-compatible
|
|
defaultsDeep({}, base, {
|
|
target: 'web',
|
|
entry: {
|
|
'scratch-vm': './src/index.js',
|
|
'scratch-vm.min': './src/index.js'
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'dist/web'),
|
|
filename: '[name].js'
|
|
},
|
|
module: {
|
|
loaders: base.module.loaders.concat([
|
|
{
|
|
test: require.resolve('./src/index.js'),
|
|
loader: 'expose?VirtualMachine'
|
|
}
|
|
])
|
|
}
|
|
}),
|
|
// Node-compatible
|
|
defaultsDeep({}, base, {
|
|
target: 'node',
|
|
entry: {
|
|
'scratch-vm': './src/index.js'
|
|
},
|
|
output: {
|
|
library: 'VirtualMachine',
|
|
libraryTarget: 'commonjs2',
|
|
path: path.resolve(__dirname, 'dist/node'),
|
|
filename: '[name].js'
|
|
}
|
|
}),
|
|
// Playground
|
|
defaultsDeep({}, base, {
|
|
target: 'web',
|
|
entry: {
|
|
'scratch-vm': './src/index.js',
|
|
'vendor': [
|
|
// FPS counter
|
|
'stats.js/build/stats.min.js',
|
|
// Syntax highlighter
|
|
'highlightjs/highlight.pack.min.js',
|
|
// Scratch Blocks
|
|
'scratch-blocks/dist/vertical.js',
|
|
// Renderer
|
|
'scratch-render',
|
|
// Audio
|
|
'scratch-audio'
|
|
]
|
|
},
|
|
output: {
|
|
path: path.resolve(__dirname, 'playground'),
|
|
filename: '[name].js'
|
|
},
|
|
module: {
|
|
loaders: base.module.loaders.concat([
|
|
{
|
|
test: require.resolve('./src/index.js'),
|
|
loader: 'expose?VirtualMachine'
|
|
},
|
|
{
|
|
test: require.resolve('stats.js/build/stats.min.js'),
|
|
loader: 'script'
|
|
},
|
|
{
|
|
test: require.resolve('highlightjs/highlight.pack.min.js'),
|
|
loader: 'script'
|
|
},
|
|
{
|
|
test: require.resolve('scratch-blocks/dist/vertical.js'),
|
|
loader: 'expose?Blockly'
|
|
},
|
|
{
|
|
test: require.resolve('scratch-render'),
|
|
loader: 'expose?RenderWebGL'
|
|
},
|
|
{
|
|
test: require.resolve('scratch-audio'),
|
|
loader: 'expose?AudioEngine'
|
|
}
|
|
])
|
|
},
|
|
plugins: base.plugins.concat([
|
|
new CopyWebpackPlugin([{
|
|
from: 'node_modules/scratch-blocks/media',
|
|
to: 'media'
|
|
}, {
|
|
from: 'node_modules/highlightjs/styles/zenburn.css'
|
|
}])
|
|
])
|
|
})
|
|
];
|