Skip to content

Instantly share code, notes, and snippets.

Avatar
🏗️
Shaping my dreams into a digital form

Sinclair trulysinclair

🏗️
Shaping my dreams into a digital form
View GitHub Profile
View .noderalis.ts
// ~/.noderalis.ts
import { ProjectConfiguration } from '@noderalis/core';
import { CleanWebpackPlugin } from 'clean-webpack-plugin';
console.log('Success!!!');
ProjectConfiguration.create({
builds: [
{
entry: async () => ProjectConfiguration.workspace('@noderalis/cli'), // C:\...\noderalis\packages\noderalis-cli\sources\index.ts
View ProjectConfiguration.ts
// ~/packages/noderalis-core/sources/ProjectConfiguration.ts
import { createRequire, createRequireFromPath } from 'module';
require(path.resolve(__dirname, `../../../.pnp.js`)).setup();
const requireAbs = (createRequire || createRequireFromPath)(
path.resolve(__dirname, './ProjectConfiguration.js')
);
async function requireConfig() {
const rootDir = await this.findProjectCwd(process.cwd(), true);
View cli.ts
import { Cli } from 'clipanion';
import { Readable, Writable } from 'stream';
import { readdirSync } from 'fs';
import { join } from 'path';
export type CommandContext = {
cwd: string;
quiet: boolean;
stdin: Readable;
stdout: Writable;
View BaseCommand.ts
// src/tools/BaseCommand.ts
import { Command } from 'clipanion';
import { CommandContext } from '..';
/**
* The BaseCommand allows us to add behind-the-scenes functionality,
* while also allowing us to now have to add Command<CommandContext>
* to every command manually.
*/
export abstract class BaseCommand extends Command<CommandContext> {
View typescript.config.ts
import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { resolve } from "path";
import { Configuration } from "webpack";
import { cpus } from "os";
const PnpPlugin = require("pnp-webpack-plugin");
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
const config: Configuration = {
entry: {
@trulysinclair
trulysinclair / pnp.config.ts
Last active June 22, 2020 23:22
This is part of my article Yarn 2 and TypeScript: Adding Webpack, https://medium.com/@thegrimsilence/yarn-2-and-typescript-adding-webpack-9dd9d24001f7.
View pnp.config.ts
import { Configuration } from "webpack";
import { resolve } from "path";
// Unfortunately pnpwp lacks TypeScript typings.
const PnpPlugin = require("pnp-webpack-plugin");
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
const config: Configuration = {
entry: {
app: resolve(__dirname, "path-to-your-file.js"),
@trulysinclair
trulysinclair / base.config.ts
Last active June 22, 2020 23:19
This is part of my article Yarn 2 and TypeScript: Adding Webpack, https://medium.com/@thegrimsilence/yarn-2-and-typescript-adding-webpack-9dd9d24001f7.
View base.config.ts
import { Configuration } from "webpack";
import { resolve } from "path";
/** Check if we're using development or production. */
const isProductionBuild: boolean = process.env.NODE_ENV == "production";
/** A basic Webpack config, using some TypeScript sytactic sugar. */
const config: Configuration = {
// Here we name our entry "app", you can also add others with any non-reserved names.
entry: {
@trulysinclair
trulysinclair / package.json
Created June 22, 2020 05:54
The simple scripts needed to get webpack running.
View package.json
{
"name": "webpack-starter",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "NODE_ENV=production && yarn _webpack",
"start": "node ./dist/file-example.js",
"_webpack": "webpack-cli --config ./config/webpack.config.ts"
}
}
View webpack.config.ts
import { CleanWebpackPlugin as CleanPlugin } from "clean-webpack-plugin";
import TsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { cpus } from "os";
import { resolve } from "path";
import { Configuration } from "webpack";
const PnpPlugin = require("pnp-webpack-plugin");
/** Name of the entry and output file. */
const simpleEntryName = "file-example";
/** Determine if this a production build. */
@trulysinclair
trulysinclair / fresh-install.ps1
Last active June 28, 2019 03:37
Automated Windows 10 fresh install
View fresh-install.ps1
# =====================================================================
# Copyright 2019 - Present TheGrimSilence
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software