How to use webpack-virtual-modules - 4 common examples

To help you get started, we’ve selected a few webpack-virtual-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github folio-org / stripes-core / test / webpack / stripes-config-plugin.spec.js View on Github external
beforeEach(function () {
      this.sandbox.stub(stripesModuleParser, 'parseAllModules').returns({ config: 'something', metadata: 'something' });
      this.sandbox.stub(VirtualModulesPlugin.prototype, 'writeModule').returns({});
      this.sandbox.stub(stripesSerialize, 'serializeWithRequire').returns({});
      this.sut = new StripesConfigPlugin(mockConfig);

      compilerStub.plugins = [];

      const translationPlugin = new StripesTranslationsPlugin({ config: {} });
      translationPlugin.allFiles = { en: '/translations/stripes-core/en.json' };
      compilerStub.options.plugins.push(translationPlugin);

      const brandingPlugin = new StripesBrandingPlugin({});
      brandingPlugin.serializedBranding = JSON.stringify({ logo: { alt: 'Future Of Libraries Is Open' } });
      compilerStub.options.plugins.push(brandingPlugin);

      this.sut.apply(compilerStub);
    });
github sysgears / apollo-universal-starter-kit / tools / webpack.run.js View on Github external
source: true,
      errors: true,
      errorDetails: true,
      warnings: true,
      publicPath: false,
      colors: true
    }));

    if (!__DEV__) {
      mkdirp.sync(outputPath);
      fs.writeFileSync(path.join(outputPath, 'stats.json'), JSON.stringify(stats.toJson()));
    }
  }
}

let frontendVirtualModules = new VirtualModules({ 'node_modules/backend_reload.js': '' });

class MobileAssetsPlugin {
  constructor(vendorAssets) {
    this.vendorAssets = vendorAssets || [];
  }

  apply(compiler) {
    const self = this;
    compiler.plugin('after-compile', (compilation, callback) => {
      _.each(compilation.chunks, chunk => {
        _.each(chunk.files, file => {
          if (file.endsWith('.bundle')) {
            let assets = self.vendorAssets;
            compilation.modules.forEach(function(module) {
              if (module._asset) {
                assets.push(module._asset);
github Shopify / quilt / packages / react-server-webpack-plugin / src / react-server-webpack-plugin.ts View on Github external
apply(compiler: Compiler) {
    const modules = this.modules(compiler);
    const virtualModules = new VirtualModulesPlugin(modules);
    (virtualModules as any).apply(compiler);
  }
github cdmbase / fullstack-pro / tools / webpack.run.js View on Github external
warnings: true,
      publicPath: false,
      colors: true
    }));

    if (!__DEV__) {
      const dir = log === logFront ?
        settings.frontendBuildDir :
        settings.backendBuildDir;
      createDirs(dir);
      fs.writeFileSync(path.join(dir, 'stats.json'), JSON.stringify(stats.toJson()));
    }
  }
}

var frontendVirtualModules = new VirtualModules({ 'node_modules/backend_reload.js': '' });

function startClient() {
  try {
    const reporter = (...args) => webpackReporter(logFront, ...args);

    clientConfig.plugins.push(frontendVirtualModules);

    if (__DEV__) {
      _.each(clientConfig.entry, entry => {
        if (settings.reactHotLoader) {
          entry.unshift('react-hot-loader/patch');
        }
        entry.unshift(
          `webpack-dev-server/client?http://localhost:${settings.webpackDevPort}/`,
          'webpack/hot/dev-server');
      });

webpack-virtual-modules

Webpack Virtual Modules

MIT
Latest version published 7 months ago

Package Health Score

81 / 100
Full package analysis

Popular webpack-virtual-modules functions