fixed little bug

This commit is contained in:
Tobias Koppers 2013-05-14 13:55:06 +02:00
parent b5f7c36a29
commit 55149353d4
3 changed files with 2 additions and 33 deletions

View File

@ -16,7 +16,7 @@ module.exports = NodeStuffPlugin;
NodeStuffPlugin.prototype.apply = function(compiler) {
function ignore() { return true; }
var context = this.context;
if(this.options.__filename) {
if(this.options.__filename == "mock") {
compiler.parser.plugin("expression __filename", function(expr) {
this.state.current.addVariable("__filename", JSON.stringify("/index.js"));
return true;

View File

@ -1,31 +0,0 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
function NodeStuffRealPathsPlugin(context, onlyIfInContext) {
this.context = context;
this.onlyIfInContext = onlyIfInContext;
}
module.exports = NodeStuffRealPathsPlugin;
NodeStuffRealPathsPlugin.prototype.apply = function(compiler) {
var context = this.context;
var onlyIfInContext = this.onlyIfInContext;
compiler.parser.plugin("expression __filename", function(expr) {
if(!this.state.module) return;
if(onlyIfInContext && this.state.module.resource.indexOf(context) != 0) return;
this.state.current.addVariable("__filename", JSON.stringify(
context ? path.relative(context, this.state.module.resource) : this.state.module.resource
));
return true;
});
compiler.parser.plugin("expression __dirname", function(expr) {
if(!this.state.module) return;
if(onlyIfInContext && this.state.module.context.indexOf(context) != 0) return;
this.state.current.addVariable("__dirname", JSON.stringify(
context ? path.relative(context, this.state.module.context) : this.state.module.context
));
return true;
});
};

View File

@ -1,6 +1,6 @@
{
"name": "webpack",
"version": "0.10.0-beta13",
"version": "0.10.0-beta14",
"author": "Tobias Koppers @sokra",
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
"dependencies": {