prepost-loader
v1.0.1
Published
A loader add prefix or postfix string to source file for webpack.
Maintainers
Readme
prepost loader for webpack
A loader add prefix or postfix string to source file for webpack. based on imports-loader
Installation
npm install prepost-loaderUsage Examples
- Auto import
ReactandReact.Componentfor all.jsxfiles.
// ./webpack.config.js
module.exports = {
...
module: {
loaders: [
{
test: /\.jsx$/,
loader: "prepost",
query: {
prefix: ['var React = require("react");', 'var Component = React.Component;'],
postfix: ''
}
}
]
};- If you have tow files:
/path/to/foo.jsxand/path/to/foo.sass. Every time you requirefoo.jsx, you want auto requirefoo.sass, then you can write something like this in webpack config file.
// ./webpack.config.js
module.exports = {
...
module: {
loaders: [
{
test: /\.jsx$/,
loader: "prepost",
query: {
autoRequireExtensions: ['sass', 'scss', 'css']
}
}
]
};