mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-06-26 20:20:23 -04:00
* chore: add Typescript dependencies * chore: add tsconfig.json * chore: update webpack.config.js for TS compatibility * chore: convert index.js to TS
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
const path = require("path");
|
|
|
|
// Base config that applies to either development or production mode.
|
|
const config = {
|
|
entry: "./src/index.ts",
|
|
output: {
|
|
library: "ScratchBlocks",
|
|
libraryTarget: "commonjs2",
|
|
path: path.resolve(__dirname, "dist"),
|
|
filename: "[name].js",
|
|
},
|
|
resolve: {
|
|
extensions: [".ts", ".js"],
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.ts$/,
|
|
use: "ts-loader",
|
|
exclude: /node_modules/,
|
|
},
|
|
],
|
|
},
|
|
// Enable webpack-dev-server to get hot refresh of the app.
|
|
devServer: {
|
|
static: "./build",
|
|
},
|
|
};
|
|
|
|
module.exports = (env, argv) => {
|
|
if (argv.mode === "development") {
|
|
// Set the output path to the `build` directory
|
|
// so we don't clobber production builds.
|
|
config.output.path = path.resolve(__dirname, "build");
|
|
|
|
// Generate source maps for our code for easier debugging.
|
|
// Not suitable for production builds. If you want source maps in
|
|
// production, choose a different one from https://webpack.js.org/configuration/devtool
|
|
config.devtool = "eval-cheap-module-source-map";
|
|
|
|
// Include the source maps for Blockly for easier debugging Blockly code.
|
|
config.module.rules.push({
|
|
test: /(blockly\/.*\.js)$/,
|
|
use: [require.resolve("source-map-loader")],
|
|
enforce: "pre",
|
|
});
|
|
|
|
// Ignore spurious warnings from source-map-loader
|
|
// It can't find source maps for some Closure modules and that is expected
|
|
config.ignoreWarnings = [/Failed to parse source map/];
|
|
}
|
|
return config;
|
|
};
|