1.0.4 • Published 6 years ago
@friends-of-js/include-import-loader v1.0.4
@friends-of-js/include-import-loader
Webpack loader for including files in your bundles, that can be usefull in testing
Install
npm install --save-dev @friends-of-js/include-import-loader
Usage
webpack.config.js
const path = require('path')
module.exports = {
module: {
rules: [
{
enforce: 'pre',
test: /\.spec\.js$/,
use: [
{
loader: '@friends-of-js/include-import-loader',
options: {
type: 'import',
files: [
path.resolve(__dirname, 'prepare/test-environment.js')
]
}
}
]
}
]
}
}
Generated code
This loader would add at top of your spec bundles this code:
import 'absolute_path/prepare/test-environment.js'
// your code
If your set type to 'require', it would produce this code:
require('absolute_path/prepare/test-environment.js')
// your code
Options
Name | Type | Default | Description |
---|---|---|---|
type | {String} | require | 'import' or 'require' |
files | {String[]} | undefined | Specify array of files to include in your code. Should be an absolute path. If you specify files property - file property would be ignored |
file | {String} | undefined | Specify file to include in your code. Should be an absolute path. |
License
@friends-of-js/include-import-loader © Dmitriy Romanov, released under the MIT License. Authored and maintained with help from contributors (list).