草庐IT

webpack-theme-color-replacer

全部标签

javascript - 如何使用具有多个入口点的 Webpack 和 Gulp 来转换应用程序和测试目录?

我正在构建一个基本的博客项目来练习使用React、ES6和Mocha测试框架。在我的defaultGulp任务中转换我的ES6测试和应用程序代码时遇到问题。当我运行default任务并将./test/posts.js的内容更改为watch时出现此错误生效:[11:17:29]Usinggulpfile~/WebstormProjects/blog/gulpfile.js[11:17:29]Starting'default'...[11:17:29]Finished'default'after8.54msstream.js:75thrower;//Unhandledstreamerror

javascript - Webpack 未捕获引用错误 : require is not defined after removing node_modules from bundle. js

bundle.js2.83kB0[emitted]mainbundle.js.map3.36kB0[emitted]main当我将下面的代码添加到自定义外部时,我可以删除node_modules,使其不直接包含在bundle.js输出中。bundle.js743kB0[emitted]mainbundle.js.map864kB0[emitted]main这显着减小了包的大小。但我在浏览器中收到一条错误消息:UncaughtReferenceError:requireisnotdefined在浏览器中。有谁知道如何解决这个问题?varpath=require("path"),fs=re

javascript - 使用 Html Webpack 插件时如何在 <head> 和 <body> 标签内添加某些脚本标签

我正在使用HtmlWebpackPlugin通过javascript生成HTML文件。现在我想在的不同部分添加自定义脚本和标签例子:我该怎么办,添加alert('inheadtag')里面标记为第一个child添加alert('inbodytag')里面标记为第一个child这是我的Webpack配置中的片段newHtmlWebpackPlugin({hash:true,chunks:["app"],filename:path.resolve(__dirname,"./public/pages/app.html"),title:"Titleofwebpage",template:pat

javascript - jQuery + 扩展 Object.prototype = "c.replace is not a function"

我在我的开源项目中使用jQuery1.5,我自己的Javascript代码中也出现了以下行:/***Object.isEmpty()**@returns{Boolean}*/Object.prototype.isEmpty=function(){/***@deprecatedSinceJavascript1.8.5*@seehttps://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object*/if(this.__count__!==undefined){returnthis.__count__===0?

javascript - 未捕获的类型错误 : Cannot call method 'replace' of undefined underscore. js

我是backbone.js和underscore.js的新手。HTML:我调用View文件的地方:JS函数(与javascript项目配合良好):functionCart(){......this.showCart=function(){varitem=deserializeJSONToObj(window.localStorage.getItem(Cart.storageName));varstr='';str+='ItemtobuyQuantity';$.each(item,function(i,item){str+=''+trimString(item.Name,50)+'Ava

javascript - D3 过渡 : Fading in and out the colors within a gradient fill

在这个D3图中,圆圈填充了径向渐变,并且改变不透明度用于淡入和淡出:varwidth=400,height=400,padding=1.5,//separationbetweensame-colornodesclusterPadding=6,//separationbetweendifferent-colornodesmaxRadius=12;varn=200,//totalnumberofnodesm=10;//numberofdistinctclustersvarcolor=d3.scale.category10().domain(d3.range(m));//Thelargest

javascript - Webpack 简单地将一堆 Pug 模板编译成 HTML

我开始使用webpack,但我终生无法解决的一件事是如何获取一个充满.pug模板的文件夹(可能包含嵌套文件夹),然后简单地将它们编译为静态html并将它们放入输出文件夹,为源模板文件夹中的每个输出html文件维护任何嵌套文件夹结构...我不想手动指定每个单独的.pug文件,我绝对不希望webpack尝试将.pugs解析为JS,然后尝试在pug文件中要求/导入任何imgs/fonts等然后提示它,我刚刚完成了基本的静态1:1编译,输入pug文件,输出html文件。为什么这么难做到? 最佳答案 使用pug-html-loader将.pu

javascript - 在 Webpack 4 中全局包含额外的 jQuery 插件

我正在尝试使用Webpack4使jQuery插件可访问内联JavaScript。我正在使用PluginProvider使jQuery可用于我的网站:plugins:[newwebpack.ProvidePlugin({"$":"jquery","jQuery":"jquery"}),],这工作正常,我可以从包含我的包的任何页面访问jQuery。我尝试添加bootstrap-datepicker通过创建一个名为vendor.js的包内容如下:import'bootstrap-datepicker';我可以打电话$('input').datepicker()来自vendor.js捆绑,但是

Javascript replace() 和 $1 问题

我正在尝试创建一个脚本来搜索文本中的模式,并在它找到的字符串周围加上一个标签。$(".shop_attributestd").each(function(){$(this).html(function(i,html){returnhtml.replace(/E[0-9]{3,4}/g,"$1");});});这是我使用的代码,它确实找到了我正在查找的内容,但它实际上所做的是生成一个包含$1的标签。我期望它做的是将它找到的字符串放入强标签中。我在这里做错了什么? 最佳答案 您需要捕获匹配项,然后才能使用它。使用括号:$(".shop_

javascript - { React jsx babel es6 webpack } 如何在 render 中评论 ( return (//||/**/) )?

我上周开始了一个项目。在回到我的团队之前,我想评论一下我的代码。/*JustfortheSyntaxoutlook*/classFooextendsReact.Components{constructor(props){super(props);}render(){return(/*cannotcommit!!!!**Followingwillthrowerrorwhenbundledwithwebpack*///Thisthrowserroraswell.)}}代码可能看起来像评论一样有效,但当前JSbin的设置未在ES6上设置。当您使用jsx通过webpack运行bundle时,它