Tag: css

webpack – require('node_modules / leaflet / leaflet.css')

所以我正在尝试使用webpack和leaflet构build一个地图应用程序。 我可以从我的map.js文件中需要leaflet.js ,但是我不能调用leaflet.css而不会收到错误。 我目前的webpack.config.js看起来像: 'use strict' var webpack = require('webpack'), path = require('path'), HtmlWebpackPlugin = require('html-webpack-plugin'), srcPath = path.join(__dirname, 'src'); module.exports = { target: "web", cache: true, entry: { app: path.join(srcPath, "index.js") }, resolve: { alais: { leaflet_css: __dirname + "/node_modules/leaflet/dist/leaflet.css" } }, module: { loaders: [ {test: /\.js?$/, exclude: /node_modules/, loader: "babel-loader"}, {test: /\.scss?$/, […]

它的安装命令clean-css在哪里?

我下载了nodes.js v0.10.15-linux-x86,并将其添加到path中,以便只能由我使用。 我安装了clean-css@1.1.3。 但是,安装后,我找不到任何地方。 npm http GET https://registry.npmjs.org/clean-css npm http 200 https://registry.npmjs.org/clean-css npm http GET https://registry.npmjs.org/clean-css/-/clean-css-1.1.3.tgz npm http 200 https://registry.npmjs.org/clean-css/-/clean-css-1.1.3.tgz npm http GET https://registry.npmjs.org/commander npm http 200 https://registry.npmjs.org/commander npm http GET https://registry.npmjs.org/commander/-/commander-2.0.0.tgz npm http 200 https://registry.npmjs.org/commander/-/commander-2.0.0.tgz clean-css@1.1.3 node_modules/clean-css └── commander@2.0.0 我查看了node / lib / node_modules /目录,没有这样的名为“clean-css”的目录。 你能看到设置有什么问题吗? 谢谢

带有webpack css-loader的源文件

我正在努力获得与CSS加载器的源代码。 在控制台中输出: 来自css-loader的文档说: SourceMaps 要包含SourceMaps,请设置sourceMap查询参数。 要求( “CSS-装载机?sourceMap!./ file.css”) 我的webpack.config var webpack = require('webpack') module.exports = { entry: './src/client/js/App.js', output: { path: './public', filename: 'bundle.js', publicPath: '/' }, plugins: process.env.NODE_ENV === 'production' ? [ new webpack.optimize.DedupePlugin(), new webpack.optimize.OccurrenceOrderPlugin(), new webpack.optimize.UglifyJsPlugin() ] : [], module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader?presets[]=es2015&presets[]=react' }, { […]

使用Webpack,是否可以仅生成CSS,不包括output.js?

我正在用extract-text-webpack-plugin使用Webpack 。 在我的项目中,我有一些构build脚本。 其中一个构build脚本应该只捆绑和缩小CSS。 由于我使用其他脚本的Webpack,我发现使用Webpack是个好主意,即使我只想捆绑和缩小CSS 。 它工作正常,除了我不能摆脱output.js文件。 我不想要结果的webpack输出文件。 我只想为这个特定的脚本的CSS。 有没有办法摆脱由此产生的JS? 如果没有,你是否build议其他特定的工具来处理CSS? 谢谢。

检测源代码是CSS / HTML / JavaScript

我想在某些来源上使用js美化 ,但是没有办法来检测它是什么types的来源。 有没有办法,粗糙或不检测,如果源是CSS,HTML,JavaScript或没有? 看着他们的网站,他们有这个看起来像它会弄清楚,如果它是HTML的: function looks_like_html(source) { // <foo> – looks like html // <!–\nalert('foo!');\n–> – doesn't look like html var trimmed = source.replace(/^[ \t\n\r]+/, ''); var comment_mark = '<' + '!-' + '-'; return (trimmed && (trimmed.substring(0, 1) === '<' && trimmed.substring(0, 4) !== comment_mark)); } 只需要看看是否是CSS,JavaScript或不。 这在node.js中运行 所以这段代码需要告诉我这是JavaScript: var foo = { bar […]

有没有任何积极的CSS缩小工具?

我想知道是否有人知道一个工具,将积极重写CSS来更有效地压缩样式。 我想: .foo { color : red; font-size: 16px; height: 20px; } .bar { color : red; font-size: 16px; height: 30px; } 被压缩到: .foo, .bar { color : red; font-size : 16px; } .foo { height : 20px; } .bar { height : 30px; } 为了清楚起见,我所知道的所有缩小器,例如YUI Compressor,只删除空格,并且可能会join一些属性(如font-family和font-size为font )。 我正在寻找一些愿意完整地重写文件结构的东西。 简而言之,如果有人知道任何人的工作背后的压缩逻辑,这个信息将不胜感激。 如果找不到我想写的东西,但是还有一百万的东西需要考虑,比如页margin-top , margin ,select器特殊性和包含顺序等等等等。如何有效地压缩信息,如重复select器或属性会更有效率?

为手写笔设置自动编译

我已经在我的Mac上安装了node.js / stylus / nib,我可以在命令行上手动编译.styl文件到css。 我也知道有这个stylus.middleware()的东西,当我search如何设置自动编译时,.styl改变,但我不知道我应该如何实现它(我从来没有使用节点。之前的js)。 我把这个代码放在哪个文件中? 我如何启动这个代码,以便它始终运行? 我想我在节点端遗漏了一些能够设置的东西。

如何使用node,express和ejs包含css文件?

我试图按照说明https://stackoverflow.com/a/18633827/2063561 ,但我仍然无法让我的styles.css加载。 从app.js app.use(express.static(path.join(__dirname, 'public'))); 在我的.ejs中,我已经尝试了这两行 <link rel="stylesheet" type="text/css" href="/css/style.css" /> <link rel="stylesheet" type="text/css" href="/public/css/style.css" /> 既不加载CSS。 我已经进入开发人员的控制台,注意到types被设置为“text / html”而不是“text / css”。 我的path看起来像 . ./app.js ./public /css /style.css

Webpack – sass loader无法find图片

sass loader文档说: "If you're just generating CSS without passing it to the css-loader, it must be relative to your web root" 。 所以我做了,因为它告诉,我有我的index.html在我的project root ,然后我试图从我的scss文件加载image 。 现在我有两个错误:1)从Chrome's console : Cannot find module "./img/header.jpg" 。 2)从我的terminal : ERROR in ./~/css-loader!./~/sass-loader!./~/resolve-url-loader!./public/css/header.scss Module not found: Error: Cannot resolve 'file' or 'directory' ./img/header.jpg in C:\Web-Development\React\Portfolio\public\css @ ./~/css-loader!./~/sass-loader!./~/resolve-url-loader!./public/css/header.scss 6:64-91 webpack.config.js […]

CSSparsing器的JavaScript?

我想parsing一个CSS blob到AST,所以我可以添加前缀到某些CSS指令。 是否有一个JavaScript或节点的CSSparsing器,将这样做? 我搜查了NPM。 我发现的唯一有用的结果是parser-lib ,但它是基于stream的,看起来我需要为每个CSS节点编写自己的发射器。 更新:我也发现JSCSSP ,但它没有文档…