mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-21 11:39:14 -04:00
Provide playground dependencies with webpack
This confines all the files the playground needs to the playground directory.
This commit is contained in:
parent
2d736f2b87
commit
a99f9ad5ff
4 changed files with 103 additions and 46 deletions
|
@ -1,3 +1,5 @@
|
|||
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
var defaultsDeep = require('lodash.defaultsdeep');
|
||||
var webpack = require('webpack');
|
||||
|
||||
var base = {
|
||||
|
@ -6,9 +8,6 @@ var base = {
|
|||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
}, {
|
||||
test: require.resolve('./src/index.js'),
|
||||
loader: 'expose?VirtualMachine'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -23,23 +22,89 @@ var base = {
|
|||
]
|
||||
};
|
||||
|
||||
module.exports = [Object.assign({}, base, {
|
||||
entry: {
|
||||
'vm': './src/index.js',
|
||||
'vm.min': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
}
|
||||
}), Object.assign({}, base, {
|
||||
entry: {
|
||||
'dist': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
library: 'VirtualMachine',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
}
|
||||
})];
|
||||
module.exports = [
|
||||
// Web-compatible, playground
|
||||
defaultsDeep({}, base, {
|
||||
entry: {
|
||||
'vm': './src/index.js',
|
||||
'vm.min': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
},
|
||||
module: {
|
||||
loaders: base.module.loaders.concat([
|
||||
{
|
||||
test: require.resolve('./src/index.js'),
|
||||
loader: 'expose?VirtualMachine'
|
||||
}
|
||||
])
|
||||
}
|
||||
}),
|
||||
// Webpack-compatible
|
||||
defaultsDeep({}, base, {
|
||||
entry: {
|
||||
'dist': './src/index.js'
|
||||
},
|
||||
output: {
|
||||
library: 'VirtualMachine',
|
||||
libraryTarget: 'commonjs2',
|
||||
path: __dirname,
|
||||
filename: '[name].js'
|
||||
}
|
||||
}),
|
||||
// Playground
|
||||
defaultsDeep({}, base, {
|
||||
entry: {
|
||||
'playground/vm': './src/index.js',
|
||||
'playground/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'
|
||||
]
|
||||
},
|
||||
output: {
|
||||
path: __dirname,
|
||||
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'
|
||||
}
|
||||
])
|
||||
},
|
||||
plugins: base.plugins.concat([
|
||||
new CopyWebpackPlugin([{
|
||||
from: 'node_modules/scratch-blocks/media',
|
||||
to: 'playground/media'
|
||||
}, {
|
||||
from: 'node_modules/highlightjs/styles/zenburn.css',
|
||||
to: 'playground'
|
||||
}])
|
||||
])
|
||||
})
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue