Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a728675
commit 1e2f3a1
Showing
23 changed files
with
270 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
module.exports = { | ||
testEnvironment: 'node', | ||
globalSetup: '<rootDir>/globalSetup.js', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class PreCopyPlugin { | ||
constructor(options = {}) { | ||
this.options = options.options || {}; | ||
} | ||
|
||
apply(compiler) { | ||
const plugin = { name: 'PreCopyPlugin' }; | ||
|
||
compiler.hooks.emit.tapAsync(plugin, (compilation, callback) => { | ||
this.options.existingAssets.forEach((assetName) => { | ||
// eslint-disable-next-line no-param-reassign | ||
compilation.assets[assetName] = { | ||
source() { | ||
return 'existing'; | ||
}, | ||
}; | ||
}); | ||
|
||
callback(); | ||
}); | ||
} | ||
} | ||
|
||
export default PreCopyPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default (compiler) => { | ||
return new Promise((resolve, reject) => { | ||
compiler.run((error, stats) => { | ||
if (error) { | ||
return reject(error); | ||
} | ||
|
||
return resolve({ stats, compiler }); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// Entry point for tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import path from 'path'; | ||
|
||
import webpack from 'webpack'; | ||
import { createFsFromVolume, Volume } from 'memfs'; | ||
|
||
export default (config = {}) => { | ||
const fullConfig = { | ||
mode: 'development', | ||
context: path.resolve(__dirname, '../fixtures'), | ||
entry: path.resolve(__dirname, '../helpers/enter.js'), | ||
output: { | ||
path: path.resolve(__dirname, '../build'), | ||
}, | ||
...config, | ||
}; | ||
|
||
if (webpack.version[0] === 5) { | ||
fullConfig.stats.source = true; | ||
} | ||
|
||
const compiler = webpack(fullConfig); | ||
|
||
if (!config.outputFileSystem) { | ||
const outputFileSystem = createFsFromVolume(new Volume()); | ||
// Todo remove when we drop webpack@4 support | ||
outputFileSystem.join = path.join.bind(path); | ||
|
||
compiler.outputFileSystem = outputFileSystem; | ||
} | ||
|
||
return compiler; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import compile from './compile'; | ||
import getCompiler from './getCompiler'; | ||
import readAsset from './readAsset'; | ||
import readAssets from './readAssets'; | ||
|
||
export { compile, getCompiler, readAsset, readAssets }; |
Oops, something went wrong.