10 examples of 'webpack file loader' in JavaScript

Every line of 'webpack file loader' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
56constructor( private webpack: any) { }
166addLoader(loader) {
167 this.loaders.push(loader);
168}
199private writeLoaderFile() {
200 writeFileSync(
201 join(this.stagingDir, `l.js`),
202 loader
203 );
204}
13function loader(source) {
14 const { limit } = loaderUtls.getOptions(this);
15
16 if (limit && limit > source.length) {
17 return `module.exports="data:${mime.getType(this.resourcePath)};base64,${source.toString('base64')}"`
18 } else {
19 return require('file-loader').call(this, source)
20 }
21}
60_emitLoad(file) {
61 this.systems.events.emit('load', file);
62}
23constructor(private _parentCompilation: any, private collectAssets: boolean = false) {
24 this._context = _parentCompilation.context;
25}
58function loader(source) {
59 this.cacheable();
60 const options = getOptions(this);
61 const result = parse.call(this, this.context, source, options);
62 const query = JSON.stringify(result.join(os.EOL));
63 const opnameInfo = OPNAME_REGEXP.exec(query);
64 const operationName = JSON.stringify((opnameInfo && opnameInfo[2]) || '');
65 if (options.string) {
66 return `module.exports = ${query}`;
67 } else {
68 return `
69 var request = require('${options.request}');
70 var url = '${options.url}';
71 module.exports = function(variables, options) {
72 var data = {
73 operationName: ${operationName},
74 query: ${query},
75 variables: JSON.stringify(variables)
76 };
77 return request(url, data, options);
78 };`
79 }
80}
22function webpackFile(outputPath, file, enc, next) {
23 // run webpack
24 webpack(webpackConfig(file.path, outputPath, env), function(err, stats) {
25 if (err) {
26 gutil.beep();
27 throw new gutil.PluginError("webpack", err);
28 }
29 gutil.log("[webpack]", stats.toString({
30 chunks: false,
31 // output options
32 }));
33 next(null, file);
34 });
35}
9function loadWebpackConfig() {
10 if (!process.env.KARMA_RUN_TYPE) {
11 process.env.KARMA_RUN_TYPE = "base";
12 return require("../webpack/webpack.config.test");
13 }
14
15 return {};
16}
42function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
43 function dirContextFrom(fileContext) {
44 return _path.default.dirname( // The first file is 'stdin' when we're using the data option
45 fileContext === 'stdin' ? resourcePath : fileContext);
46 } // eslint-disable-next-line no-shadow
47
48
49 function startResolving(dir, importsToResolve) {
50 return importsToResolve.length === 0 ? Promise.reject() : resolve(dir, importsToResolve[0]).then(resolvedFile => {
51 // Add the resolvedFilename as dependency. Although we're also using stats.includedFiles, this might come
52 // in handy when an error occurs. In this case, we don't get stats.includedFiles from node-sass.
53 addNormalizedDependency(resolvedFile);
54 return {
55 // By removing the CSS file extension, we trigger node-sass to include the CSS file instead of just linking it.
56 file: resolvedFile.replace(matchCss, '')
57 };
58 }, () => {
59 const [, ...tailResult] = importsToResolve;
60 return startResolving(dir, tailResult);
61 });
62 }
63
64 return (url, prev, done) => {
65 startResolving(dirContextFrom(prev), (0, _importsToResolve.default)(url)) // Catch all resolving errors, return the original file and pass responsibility back to other custom importers
66 .catch(() => {
67 return {
68 file: url
69 };
70 }).then(done);
71 };
72}

Related snippets