Newer
Older
Steven Dale
committed
var webpack = require('webpack');
// Plugins
var CopyWebpackPlugin = require('copy-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var UglifyJsPlugin = require('uglifyjs-webpack-plugin');
Steven Dale
committed
// PostCss
var autoprefixer = require('autoprefixer');
var postcssVars = require('postcss-simple-vars');
var postcssImport = require('postcss-import');
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
devServer: {
contentBase: path.resolve(__dirname, 'build'),
host: '0.0.0.0',
port: process.env.PORT || 8601
externals: {
React: 'react',
ReactDOM: 'react-dom'
},
resolve: {
symlinks: false
},
include: [path.resolve(__dirname, 'src'), /node_modules[\\/]scratch-[^\\/]+[\\/]src/],
options: {
// Explicitly disable babelrc so we don't catch various config
// in much lower dependencies.
babelrc: false,
plugins: [
'syntax-dynamic-import',
'transform-async-to-generator',
'transform-object-rest-spread',
['react-intl', {
messagesDir: './translations/messages/'
}]],
presets: [['env', {targets: {browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']}}], 'react']
}
localIdentName: '[name]_[local]_[hash:base64:5]',
camelCase: true
}
}, {
autoprefixer({
browsers: ['last 3 versions', 'Safari >= 8', 'iOS >= 8']
})
];
}
}
}]
optimization: {
minimizer: [
new UglifyJsPlugin({
include: /\.min\.js$/
})
]
},
plugins: []
module.exports = [
// to run editor examples
defaultsDeep({}, base, {
entry: {
'lib.min': ['react', 'react-dom'],
'gui': './src/playground/index.jsx',
'blocksonly': './src/playground/blocks-only.jsx',
'compatibilitytesting': './src/playground/compatibility-testing.jsx',
'player': './src/playground/player.jsx'
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js'
},
externals: {
React: 'react',
ReactDOM: 'react-dom'
},
module: {
rules: base.module.rules.concat([
{
test: /\.(svg|png|wav|gif|jpg)$/,
loader: 'file-loader',
options: {
outputPath: 'static/assets/'
}
}
])
},
optimization: {
splitChunks: {
chunks: 'all',
name: 'lib.min'
},
runtimeChunk: {
name: 'lib.min'
}
},
plugins: base.plugins.concat([
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"' + process.env.NODE_ENV + '"',
'process.env.DEBUG': Boolean(process.env.DEBUG),
'process.env.GA_ID': '"' + (process.env.GA_ID || 'UA-000000-01') + '"'
template: 'src/playground/index.ejs',
sentryConfig: process.env.SENTRY_CONFIG ? '"' + process.env.SENTRY_CONFIG + '"' : null
template: 'src/playground/index.ejs',
filename: 'blocks-only.html',
title: 'Scratch 3.0 GUI: Blocks Only Example'
}),
new HtmlWebpackPlugin({
template: 'src/playground/index.ejs',
filename: 'compatibility-testing.html',
title: 'Scratch 3.0 GUI: Compatibility Testing'
}),
new HtmlWebpackPlugin({
template: 'src/playground/index.ejs',
filename: 'player.html',
title: 'Scratch 3.0 GUI: Player Example'
}),
new CopyWebpackPlugin([{
from: 'static',
to: 'static'
}]),
new CopyWebpackPlugin([{
from: 'node_modules/scratch-blocks/media',
to: 'static/blocks-media'
}]),
new CopyWebpackPlugin([{
from: 'extensions/**',
to: 'static',
context: 'src/examples'
}]),
new CopyWebpackPlugin([{
from: 'extension-worker.{js,js.map}',
context: 'node_modules/scratch-vm/dist/web'
}])
])
})
].concat(
process.env.NODE_ENV === 'production' ? (
// export as library
defaultsDeep({}, base, {
target: 'web',
entry: {
},
output: {
libraryTarget: 'umd',
path: path.resolve('dist')
},
externals: {
React: 'react',
ReactDOM: 'react-dom'
},
module: {
rules: base.module.rules.concat([
{
test: /\.(svg|png|wav|gif|jpg)$/,
loader: 'file-loader',
options: {
outputPath: 'static/assets/',
publicPath: '/static/assets/'
}
}
])
},
plugins: base.plugins.concat([
new CopyWebpackPlugin([{
from: 'node_modules/scratch-blocks/media',
to: 'static/blocks-media'
}]),
new CopyWebpackPlugin([{
from: 'extension-worker.{js,js.map}',
context: 'node_modules/scratch-vm/dist/web'
}])
])