npm install --save-dev raw-extend-loader
Use the loader either via your webpack config, CLI or inline.
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.txt$/,
use: [
{
loader: require.resolve('raw-extend-loader'),
options: {
dir: '/path/md', // Copy to the '/path/md' directory.
filename: 'dir', // "underline | dir"
sep: '___', // filename="underline", File name to the directory, using '___' interval, default value '__'.
},
},
],
}
]
}
}
dir
Copy to the '/path/md' directory.filename
Optionalunderline | dir
, According to the directory to store, or do not create a directory.sep
Setfilename="underline"
, File name to the directory, using___
interval, default value__
.
In your application
import txt from './file.txt';
webpack --module-bind 'txt=raw-extend-loader'
In your application
import txt from 'file.txt';
In your application
import txt from 'raw-extend-loader!./file.txt';