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

@nettpack/core

v1.0.4

Published

Webpack integration from Nette framework

Downloads

1

Readme

NettPack core

Nettpack core is plugin for building javascripts and styles by using WebPackConfig + Nette

How to use:

  • first create webpack configs for production and development mode

    • First please set nettpack host (path to your site) parameter in your config.local.neon parameters:

      parameters:
      	nettpack:
      		host: http://domain
    • example development config

      process.env.NODE_ENV = 'development';
      import express from "express";
      import webpack from 'webpack';
      import {NettPack} from "@nettpack/core"
      import webpackDevMiddleware from 'webpack-dev-middleware';
      import webpackHotMiddleware from 'webpack-hot-middleware';
      import fs from "fs";
      import myModule from "./path_to_your_module"
      let nett = new NettPack(__dirname + "/app/Config/config.local.neon");
      const app = express();
        	
      const regex = /(^.*[\/])(.*)(\.\w{20})(\.js|\.css)$/gi;
      app.use(function(req, res, next) {
      	if (!req.url) {
      		return;
      	}
      	let result = regex.exec(req.url);
      	if (result && result.length > 0) {
      		req.url = result[1] + result[2] + result[4];
      	}
      	next();
      });
        	
      nett.addAppModule("myModule", myModule);
        	
      let data = nett.buildModules();
        	
      for (let moduleName in data.modules) {
      	let module = data.modules[moduleName];
      	let compiler = webpack(module);
      	app.use(webpackDevMiddleware(compiler, {
      		publicPath: nett.config.publicPath + "/" + moduleName,
      		noInfo: true
      	}));
      	app.use(webpackHotMiddleware(compiler, {
      		hot: true,
      		path: nett.config.publicPath + '/' + moduleName + '/__webpack_hmr'
      	}));
      }
        	
      let content = "module.exports = " + JSON.stringify({resolve: data.resolves});
        	
      fs.writeFile('./webpack.export.config.js', content, function (err) {
      	if (err) throw err;
      	console.log('It\'s saved export webpack resolve!\n');
      });
        	
      app.listen(nett.getAppPort());
      
    • example production config

      process.env.NODE_ENV = 'production';
      import webpack from 'webpack';
      import {NettPack} from "@nettpack/core";
      import myModule from "./path_to_your_module"
      import fs from "fs";
        	
      let nett = new NettPack(__dirname + "/app/Config/config.local.neon");
      nett.addAppModule("myModule", myModule);
        	
      let data = nett.buildModules();
        	
      let hashes = [];
      for (let moduleName in data.modules) {
      	let module = data.modules[moduleName];
      	webpack(module).run((error, stats) => {
      		hashes.push({
      			name: moduleName,
      			hash: stats.hash
      		});
      		fs.writeFile('./webpack.hashes.js', JSON.stringify(hashes), function (err) {
      			if (err) throw err;
      			console.log('Hash saved!');
      		});
      		console.log(`Webpack stats: ${stats}`);
      		return 0;
      	})
      }
    • example module (each module is webpack.config.js)

      import path from 'path';
      import webpack from 'webpack';
      import ExtractTextWebpackPlugin from "extract-text-webpack-plugin";
        	
      module.exports = function () {
        	
      	let fileNameCss = '[name].[hash].css';
      	let fileNameJs = '[name].[hash].js';
      	if (process.env.NODE_ENV === 'development') {
      		fileNameCss = '[name].css';
      		fileNameJs = '[name].js';
      	}
      	const ExtractStylePlugin = new ExtractTextWebpackPlugin({
      		filename: fileNameCss,
      		disable: 'development' === process.env.NODE_ENV
      	});
      	return {
      		entry: {
      			app: [
      				path.join(__dirname, '/../pathToYourEntryPoint')
      			]
      		},
      		module: {
      			rules: [
      				{
      					test: /\.js$/,
      					use: {
      						loader: 'babel-loader'
      					}
      				},
      				{
      					test: /\.(css|less)$/,
      					use: ExtractStylePlugin.extract({
      						use: [
      							{ loader: "css-loader" },
      							{ loader: "less-loader" },
      						],
      						fallback: "style-loader"
      					})
      				},
      				{
      					test: /\.(png|gif|woff|woff2|eot|ttf|svg)$/,
      					loader: 'url-loader?limit=100000'
      				}
      			],
      		},
      		output:{
      			path: path.join(__dirname, '/../../web/dist'),
      			publicPath: "/dist",
      			filename: fileNameJs
      		},
      		plugins: [
      			new webpack.ProvidePlugin({
      				$: "jquery",
      				jquery: "jquery",
      				jQuery: "jquery"
      			}),
      			ExtractStylePlugin
      		],
      	};
      };
  • How to insert another vendor package files into build collection:

    • First you must place this settings into your composer.json in your vendor package
    {
    .........
    .........
    .........,
    .........,
    	"extra": {
    		"nettpack": {
    			"resolve": {
    				"CustomName": "./src/Assets/main.js"
    				}
    			}
    		}
    }

    or using entry points

    {
    .........
    .........
    .........,
    .........,
    	"extra": {
    		"nettpack": {
    			"entry": {
    				"CustomName": "./src/Assets/main.js"
    				}
    			}
    		}
    }
    • Now you must create main.js file into /src/Assets, for example
    export * from './pathToYourJsFile.js'
    import './pathToYourStyles.less'
  • For run build or start development mode place this scripts into your package.json file:

    {
    	"scripts": {
    		"start": "npm run build && npm run babel-node",
    		"prebuild": "npm run clean-dist",
    		"clean-dist": "npm run remove-dist && mkdir ./web/dist",
    		"remove-dist": "rimraf ./web/dist",
    		"build": "./node_modules/.bin/babel-node ./webpack.production.js",
    		"babel-node": "./node_modules/.bin/babel-node ./webpack.development.js",
    		}
    }