npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@wieni/magic

v5.0.0-beta.18

Published

Magic for Drupal themes, by Wieni.

Downloads

227

Readme

Magic

A frontend build tool, based on create-react-app. It's a black box that compiles sass (scss) and javascript (js / jsx) files.

Installation

npm install @wieni/magic.

In your Drupal 8 theme, add the folling to your package.json:

"scripts": {
  "build": "NODE_ENV=production magic build",
  "start": "NODE_ENV=development magic start",
}

Config

Configuration is done in the magic.config.js file.

entry

These are all the bundles that should be compiled. An object with key-valye pairs: the key is the output name of the bundle, the value is the filename.

Note: All bundles should be placed inside the resources folder.

module.exports = {
  entry: {
    global: "index.js",
  },
};

In this example, resources/index.js in a bundle. The output is placed inside public/resources/{files}.

alias

This allows you to use (webpack) alias resolving.

Note: All alias should be placed inside the resources folder.

module.exports = {
  ...,
  alias: {
    "@dashboard": "dashboard",
  },
};

In this example, @dashboard will resolves files from resources/dashboard.

Development config

Development configuration is done in the magic.dev.config.js file.

module.exports = {
  proxyPort: 3000,
  proxyTarget: "https://x.wieni.dev",
  proxyHost: "x.wieni.dev",
};

Gitignore

Make sure to add magic.dev.config.js to your .gitignore file. This file is unique for every developer. You can add a magic.dev.config.example.js, to provide a sample configuration.

Usage

  • magic build: Build the frontend.
  • magic start: Run a development (proxy) server.

Common problems

Unable to resolve assets used in sass/css.

ModuleNotFoundError: Module not found: Error: Can't resolve './components/category-menu/images/icon-triangle.svg' in '/public/themes/custom/drupack/resources'

ℹ️ Fix the import by using ~.

⛔️ The sass file contains an import background-image: url("images/icon-triangle.svg");.

✅ Change this import to background-image: url("~images/icon-triangle.svg");

Unexpected use of 'x' no-restricted-globals

Line 47:9: Unexpected use of 'history' no-restricted-globals

ℹ️ Compilation fails, because ESLint throws an error.

⛔️ You're calling a global variable, like history or location.

/*eslint-disable no-restricted-globals*/

My life sucks. I have to support IE11.

ℹ️ Well, might not be too hard …

npm install react-app-polyfill

In your main bundle, add the following:

import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

Add IE 11 to the browserlist in your package.json:

  "browserslist": {
    "production": [
      "IE 11",
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }