How to use the webpack-sources.ConcatSource.bind function in webpack-sources

To help you get started, we’ve selected a few webpack-sources 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 alibaba / rax / packages / miniapp-webpack-plugin / src / plugins / WebpackAssetsPlugin.js View on Github external
${SCHEMA_VAR} = ${JSON.stringify(mockData)};
            } catch(err) { 
              console.warn('Inject schema data with error', err); 
            }
          `;
          } catch (err) {
            throw new Error('Please check schema/mock-data.json is a valid JSON string.');
          }
        }

        if (injectSchemaMockData) {
          args.unshift(injectSchemaMockData);
        }

        args.unshift(ConcatSource); // firstArg for apply
        const app = new (ConcatSource.bind.apply(ConcatSource, args))();
        compilation.assets['app.js'] = app;
        global.AppJSContent = app.source();
      });
    });
github alibaba / rax / packages / miniapp-builder / src / plugins / WebpackMiniProgramPlugin.js View on Github external
compilation.hooks.optimizeAssets.tap('MiniAppPlugin', () => {
        const args = Object.values(compilation.assets);

        // polyfill global context
        args.unshift(new ConcatSource(globalPolyfills.join('')));
        args.unshift(ConcatSource);

        const app = new (ConcatSource.bind.apply(ConcatSource, args))();

        // 删除原 assets
        Object.keys(compilation.assets).forEach((key) => {
          delete compilation.assets[key];
        });

        // 增加 app.js
        // wrapper for app.js
        compilation.assets['app.js'] = app;
        global.AppJSContent = app.source();

        let injectSchemaMockData;
        const mockDataPath = join(compiler.context, 'schema/mock-data.json');
        if (existsSync(mockDataPath)) {
          try {
            const mockData = JSON.parse(readFileSync(mockDataPath));
github alibaba / rax / packages / mp-loader / demo / WebpackMiniProgramPlugin.js View on Github external
compilation.hooks.optimizeAssets.tap('MiniAppPlugin', () => {
        const args = Object.values(compilation.assets);

        // polyfill global context
        args.unshift(new ConcatSource(globalPolyfills.join('')));
        args.unshift(ConcatSource);

        const app = new (ConcatSource.bind.apply(ConcatSource, args))();

        // 删除原 assets
        Object.keys(compilation.assets).forEach((key) => {
          delete compilation.assets[key];
        });

        compilation.assets['app.js'] = app;
        compilation.assets['app.web.js'] = new ConcatSource(
          '__register_pages__(function(require){',
          app,
          '});',
        );
      });
    });