1.0.1 • Published 9 years ago
prepost-loader v1.0.1
prepost loader for webpack
A loader add prefix or postfix string to source file for webpack. based on imports-loader
Installation
npm install prepost-loader
Usage Examples
Auto import
React
andReact.Component
for all.jsx
files.// ./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.jsx
and/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'] } } ] };