This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+17
View File
@@ -0,0 +1,17 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 2
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = space
indent_size = 2
+1
View File
@@ -0,0 +1 @@
less-loader
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS">
<value>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JavaScript">
<indentOptions>
<option name="USE_TAB_CHARACTER" value="true" />
<option name="SMART_TABS" value="true" />
</indentOptions>
</codeStyleSettings>
</value>
</option>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false">
<file url="PROJECT" charset="UTF-8" />
</component>
</project>
+67
View File
@@ -0,0 +1,67 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<option name="myLocal" value="false" />
<inspection_tool class="BadExpressionStatementJS" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="BlockStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ChainedEqualityJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConditionalExpressionWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ConfusingPlusesOrMinusesJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="CyclomaticComplexityJS" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_limit" value="10" />
</inspection_tool>
<inspection_tool class="DivideByZeroJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="EqualityComparisonWithCoercionJS" enabled="true" level="WEAK WARNING" enabled_by_default="true" />
<inspection_tool class="ForLoopReplaceableByWhileJS" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_ignoreLoopsWithoutConditions" value="false" />
</inspection_tool>
<inspection_tool class="HtmlUnknownAttribute" enabled="true" level="INFO" enabled_by_default="true">
<option name="myValues">
<value>
<list size="0" />
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
<inspection_tool class="HtmlUnknownTag" enabled="true" level="INFO" enabled_by_default="true">
<option name="myValues">
<value>
<list size="6">
<item index="0" class="java.lang.String" itemvalue="nobr" />
<item index="1" class="java.lang.String" itemvalue="noembed" />
<item index="2" class="java.lang.String" itemvalue="comment" />
<item index="3" class="java.lang.String" itemvalue="noscript" />
<item index="4" class="java.lang.String" itemvalue="embed" />
<item index="5" class="java.lang.String" itemvalue="script" />
</list>
</value>
</option>
<option name="myCustomValuesEnabled" value="true" />
</inspection_tool>
<inspection_tool class="IfStatementWithIdenticalBranchesJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="JSDeclarationsAtScopeStart" enabled="false" level="WEAK WARNING" enabled_by_default="false">
<option name="myMakeSingleVarStatement" value="true" />
</inspection_tool>
<inspection_tool class="JSHint" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="JSLintValidation" enabled="true" level="ERROR" enabled_by_default="true">
<option name="assumeConsole" value="true" />
<option name="assumeNodeJS" value="true" />
<option name="tolerateIncrementAndDecrement" value="true" />
<option name="tolerateDanglingUnderscoreIn" value="true" />
</inspection_tool>
<inspection_tool class="JasmineAdapterSupport" enabled="false" level="WARNING" enabled_by_default="false" />
<inspection_tool class="NegatedIfStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NestedSwitchStatementJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NestingDepthJS" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_limit" value="4" />
</inspection_tool>
<inspection_tool class="NonBlockStatementBodyJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="NonShortCircuitBooleanExpressionJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ObjectAllocationIgnoredJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="ParametersPerFunctionJS" enabled="true" level="WARNING" enabled_by_default="true">
<option name="m_limit" value="4" />
</inspection_tool>
<inspection_tool class="SwitchStatementWithNoDefaultBranchJS" enabled="true" level="WARNING" enabled_by_default="true" />
<inspection_tool class="TailRecursionJS" enabled="true" level="WARNING" enabled_by_default="true" />
</profile>
</component>
@@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>
+7
View File
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{less-loader node_modules}" />
<file url="PROJECT" libraries="{expect.js-DefinitelyTyped, mocha-DefinitelyTyped, sinon-chai-DefinitelyTyped}" />
</component>
</project>
+71
View File
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JSHintConfiguration" version="2.5.6" use-config-file="true">
<option asi="false" />
<option bitwise="true" />
<option boss="false" />
<option browser="true" />
<option camelcase="false" />
<option couch="false" />
<option curly="true" />
<option debug="false" />
<option devel="false" />
<option dojo="false" />
<option eqeqeq="true" />
<option eqnull="false" />
<option es3="false" />
<option esnext="false" />
<option evil="false" />
<option expr="false" />
<option forin="true" />
<option freeze="false" />
<option funcscope="false" />
<option gcl="false" />
<option globalstrict="false" />
<option immed="false" />
<option iterator="false" />
<option jquery="false" />
<option lastsemic="false" />
<option latedef="false" />
<option laxbreak="false" />
<option laxcomma="false" />
<option loopfunc="false" />
<option maxerr="50" />
<option mootools="false" />
<option moz="false" />
<option multistr="false" />
<option newcap="false" />
<option noarg="true" />
<option node="true" />
<option noempty="true" />
<option nomen="false" />
<option nonbsp="false" />
<option nonew="true" />
<option nonstandard="false" />
<option notypeof="false" />
<option noyield="false" />
<option onevar="false" />
<option passfail="false" />
<option phantom="false" />
<option plusplus="false" />
<option predef="describe, it" />
<option proto="false" />
<option prototypejs="false" />
<option quotmark="false" />
<option rhino="false" />
<option scripturl="false" />
<option shadow="false" />
<option smarttabs="false" />
<option strict="true" />
<option sub="false" />
<option supernew="false" />
<option trailing="false" />
<option undef="true" />
<option unused="false" />
<option validthis="false" />
<option white="false" />
<option worker="false" />
<option wsh="false" />
<option yui="false" />
</component>
</project>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="expect.js-DefinitelyTyped" level="application" />
<orderEntry type="library" name="mocha-DefinitelyTyped" level="application" />
<orderEntry type="library" name="Node.js v0.10.32 Core Modules" level="application" />
<orderEntry type="library" name="sinon-chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="less-loader node_modules" level="project" />
</component>
</module>
+14
View File
@@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="less-loader node_modules" type="javaScript">
<properties>
<option name="frameworkName" value="node_modules" />
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/node_modules" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/node_modules" />
</CLASSES>
<SOURCES />
</library>
</component>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/less-loader.iml" filepath="$PROJECT_DIR$/.idea/less-loader.iml" />
</modules>
</component>
</project>
+5
View File
@@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
+56
View File
@@ -0,0 +1,56 @@
Index: test/less/sourcemap.less
===================================================================
--- test/less/sourcemap.less (date 1425654280000)
+++ test/less/source-map.less (revision )
@@ -1,3 +1,5 @@
+@import "basic";
+
#it-works {
margin: 10px;
}
Index: test/index.test.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/index.test.js (date 1425654280000)
+++ test/index.test.js (revision )
@@ -31,8 +31,8 @@
test("should transform urls", "url-path");
test("should transform urls to files above the current directory", "folder/url-path");
test("should transform urls to files above the sibling directory", "folder2/url-path");
- test("should generate source-map", "sourcemap", {
- devtool: "sourcemap"
+ test("should generate source-map", "source-map", {
+ devtool: "source-map"
});
it("should report error correctly", function(done) {
webpack({
Index: test/css/sourcemap.css
===================================================================
--- test/css/sourcemap.css (date 1425654280000)
+++ test/css/sourcemap.css (date 1425654280000)
@@ -1,3 +0,0 @@
-#it-works {
- margin: 10px;
-}
Index: test/css/source-map.css
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/css/source-map.css (revision )
+++ test/css/source-map.css (revision )
@@ -0,0 +1,12 @@
+.box {
+ color: #fe33ac;
+ border-color: #fdcdea;
+ background: url(box.png);
+}
+.box div {
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
+}
+#it-works {
+ margin: 10px;
+}
+4
View File
@@ -0,0 +1,4 @@
<changelist name="1" date="1425655295676" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/1.patch" />
<option name="DESCRIPTION" value="1" />
</changelist>
+87
View File
@@ -0,0 +1,87 @@
Index: .jshintrc
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- .jshintrc (revision )
+++ .jshintrc (revision )
@@ -0,0 +1,48 @@
+{
+ "browser": true,
+ "node": true,
+ "expr": true,
+ "predef": [ // Extra globals.
+ "describe",
+ "it",
+ "before",
+ "after",
+ "beforeEach",
+ "afterEach"
+ ],
+
+ "curly": false, // Require {} for every new block or scope.
+ "eqeqeq": true, // Require triple equals i.e. `===`.
+ "forin": true, // Tolerate `for in` loops without `hasOwnPrototype`.
+ "immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
+ "latedef": false, // Prohibit variable use before definition.
+ "newcap": false, // Require capitalization of all constructor functions e.g. `new F()`.
+ "noempty": true, // Prohibit use of empty blocks.
+ "nonew": false, // Prohibit use of constructors for side-effects.
+ "plusplus": false, // Prohibit use of `++` & `--`.
+ "undef": true, // Require all non-global variables be declared before they are used.
+ "strict": true, // Require `use strict` pragma in every file.
+ "trailing": true, // Prohibit trailing whitespaces.
+ "asi": false, // Tolerate Automatic Semicolon Insertion (no semicolons).
+ "boss": false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
+ "debug": false, // Allow debugger statements e.g. browser breakpoints.
+ "eqnull": false, // Tolerate use of `== null`.
+ "esnext": false, // Allow ES.next specific features such as `const` and `let`.
+ "evil": false, // Tolerate use of `eval`.
+ "funcscope": false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
+ "globalstrict": false, // Allow global "use strict" (also enables 'strict').
+ "iterator": false, // Allow usage of __iterator__ property.
+ "lastsemic": false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
+ "laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
+ "laxcomma": false, // Suppress warnings about comma-first coding style.
+ "loopfunc": false, // Allow functions to be defined within loops.
+ "multistr": false, // Tolerate multi-line strings.
+ "quotmark": "double", // Only double quotes for strings.
+ "proto": false, // Tolerate __proto__ property. This property is deprecated.
+ "scripturl": false, // Tolerate script-targeted URLs.
+ "smarttabs": false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
+ "shadow": false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
+ "sub": true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
+ "supernew": false, // Tolerate `new function () { ... };` and `new Object;`.
+ "validthis": false // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function
+}
Index: test/index.test.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/index.test.js (date 1425654008000)
+++ test/index.test.js (revision )
@@ -32,7 +32,7 @@
test("should transform urls to files above the current directory", "folder/url-path");
test("should transform urls to files above the sibling directory", "folder2/url-path");
test("should generate source-map", "sourcemap", {
- devtool: 'sourcemap',
+ devtool: "sourcemap"
});
it("should report error correctly", function(done) {
webpack({
@@ -127,11 +127,11 @@
hooks.after && hooks.after();
- if (hooks.devtool === 'sourcemap') {
- actualMap = fs.readFileSync(__dirname + "/output/bundle.js.map", "utf8")
+ if (hooks.devtool === "sourcemap") {
+ actualMap = fs.readFileSync(__dirname + "/output/bundle.js.map", "utf8");
fs.writeFileSync(__dirname + "/output/" + name + ".sync.css.map", actualMap, "utf8");
actualMap = JSON.parse(actualMap);
- actualMap.sources.should.containEql('webpack:///./test/less/' + id + '.less');
+ actualMap.sources.should.containEql("webpack:///./test/less/" + id + ".less");
}
done();
+4
View File
@@ -0,0 +1,4 @@
<changelist name="2" date="1425655306663" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/2.patch" />
<option name="DESCRIPTION" value="2" />
</changelist>
@@ -0,0 +1,4 @@
<changelist name="Uncommitted_changes_before_Update_at_25_11_15__19_39__Default_" date="1448476785812" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_Update_at_25_11_15__19_39__Default_/shelved.patch" />
<option name="DESCRIPTION" value="Uncommitted changes before Update at 25.11.15, 19:39 [Default]" />
</changelist>
@@ -0,0 +1,35 @@
Index: README.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- README.md (revision 41c6caf2d20afea537a7202858bdff5a17728ef1)
+++ README.md (revision )
@@ -55,9 +55,8 @@
### LESS plugins
-In order to use [plugins](http://lesscss.org/usage/#plugins), simply define
-the `lessLoader.lessPlugins` option. You can also change the options key
-with a query parameter: `"less?config=lessLoaderCustom"`.
+In order to use [plugins](http://lesscss.org/usage/#plugins), simply set
+the `lessLoader.lessPlugins`-option on your webpack options. You can also change the options' key with a query parameter: `"less?config=lessLoaderCustom"`.
``` javascript
var LessPluginCleanCSS = require('less-plugin-clean-css');
Index: .editorconfig
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- .editorconfig (revision 41c6caf2d20afea537a7202858bdff5a17728ef1)
+++ .editorconfig (revision )
@@ -9,7 +9,7 @@
end_of_line = lf
insert_final_newline = true
indent_style = tab
-indent_size = 2
+indent_size = 4
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
@@ -0,0 +1,19 @@
Index: README.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- README.md (revision 9267cb1e8ba19079a651e7c15da4cc92d2808d72)
+++ README.md (revision )
@@ -55,9 +55,8 @@
### LESS plugins
-In order to use [plugins](http://lesscss.org/usage/#plugins), simply define
-the `lessLoader.lessPlugins` option. You can also change the options key
-with a query parameter: `"less?config=lessLoaderCustom"`.
+In order to use [plugins](http://lesscss.org/usage/#plugins), simply set
+the `lessLoader.lessPlugins`-option on your webpack options. You can also change the options' key with a query parameter: `"less?config=lessLoaderCustom"`.
``` javascript
var LessPluginCleanCSS = require('less-plugin-clean-css');
@@ -0,0 +1,4 @@
<changelist name="Uncommitted_changes_before_update_operation_at_05_10_15_22_25__Default_" date="1444076745546" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/Uncommitted_changes_before_update_operation_at_05_10_15_22_25_[Default].patch" />
<option name="DESCRIPTION" value="Uncommitted changes before update operation at 05.10.15 22:25 [Default]" />
</changelist>
+170
View File
@@ -0,0 +1,170 @@
Index: test/sourceMap/webpack.config.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/sourceMap/webpack.config.js (revision )
+++ test/sourceMap/webpack.config.js (revision )
@@ -0,0 +1,29 @@
+"use strict";
+
+var path = require("path");
+var ExtractTextPlugin = require("extract-text-webpack-plugin");
+
+var pathToLessLoader = path.resolve(__dirname, "../../index.js");
+
+module.exports = {
+ entry: path.resolve(__dirname, "./entry.js"),
+ output: {
+ path: path.resolve(__dirname, "../output"),
+ filename: "bundle.sourcemap.js"
+ },
+ devtool: "inline-source-map",
+ module: {
+ loaders: [
+ {
+ test: /\.less/,
+ loader: ExtractTextPlugin.extract(
+ "css-loader?sourceMap!" +
+ pathToLessLoader + "?sourceMap"
+ )
+ }
+ ]
+ },
+ plugins: [
+ new ExtractTextPlugin("styles.css")
+ ]
+};
Index: package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- package.json (date 1425654699000)
+++ package.json (revision )
@@ -4,13 +4,16 @@
"author": "Tobias Koppers @sokra",
"description": "less loader module for webpack",
"scripts": {
- "test": "mocha -R spec"
+ "test": "mocha -R spec",
+ "test-source-map": "webpack --config test/sourceMap/webpack.config.js && open ./test/sourceMap/index.html"
},
"peerDependencies": {
"less": "^2.3.1"
},
"devDependencies": {
+ "css-loader": "^0.9.1",
"enhanced-require": "^0.5.0-beta6",
+ "extract-text-webpack-plugin": "^0.3.8",
"less": "^2.3.1",
"mocha": "^2.0.1",
"raw-loader": "^0.5.1",
Index: test/less/imports-node.less
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/less/imports-node.less (date 1425654699000)
+++ test/less/imports-node.less (revision )
@@ -1,3 +1,9 @@
+@import (reference) "~some/module";
+@import "~some/css.css";
+@import (css) "~some/css.css";
+@import (less) "~some/css.css";
+@import (inline) "~some/css.css";
+
// Add bootstrap as sufficient complex and popular example
@import "~bootstrap/less/bootstrap.less";
Index: test/css/imports-node.css
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/css/imports-node.css (date 1425654699000)
+++ test/css/imports-node.css (revision )
@@ -1,3 +1,14 @@
+@import "~some/css.css";
+@import "~some/css.css";
+#it-works,
+#it-works {
+ color: hotpink;
+}
+.modules-dir-some-module,
+#it-works,
+#it-works {
+ background: hotpink;
+}
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
html {
font-family: sans-serif;
Index: test/sourceMap/entry.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/sourceMap/entry.js (revision )
+++ test/sourceMap/entry.js (revision )
@@ -0,0 +1,3 @@
+"use strict";
+
+require("../less/source-map.less");
Index: test/less/imports-bower.less
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/less/imports-bower.less (date 1425654699000)
+++ test/less/imports-bower.less (revision )
@@ -1,3 +1,9 @@
+@import (reference) "~some/module";
+@import "~some/css.css";
+@import (css) "~some/css.css";
+@import (less) "~some/css.css";
+@import (inline) "~some/css.css";
+
// Add bootstrap as sufficient complex and popular example
@import "~bootstrap/less/bootstrap.less";
Index: test/sourceMap/index.html
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/sourceMap/index.html (revision )
+++ test/sourceMap/index.html (revision )
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title></title>
+ <meta charset="utf-8"/>
+ <link href="../output/styles.css" type="text/css" rel="stylesheet">
+</head>
+<body>
+ <h1 id="it-works" class="box">Open the developer tools, dude!</h1>
+</body>
+</html>
Index: test/css/imports-bower.css
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/css/imports-bower.css (date 1425654699000)
+++ test/css/imports-bower.css (revision )
@@ -1,3 +1,14 @@
+@import "~some/css.css";
+@import "~some/css.css";
+#it-works,
+#it-works {
+ color: hotpink;
+}
+.modules-dir-some-module,
+#it-works,
+#it-works {
+ background: hotpink;
+}
/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
html {
font-family: sans-serif;
+4
View File
@@ -0,0 +1,4 @@
<changelist name="head" date="1425655279909" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/head.patch" />
<option name="DESCRIPTION" value="head" />
</changelist>
@@ -0,0 +1,4 @@
<changelist name="imports_fallback_https___github_com_webpack_less_loader_issues_74" date="1458934656167" recycled="false">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/imports_fallback_https___github_com_webpack_less_loader_issues_74/shelved.patch" />
<option name="DESCRIPTION" value="imports-fallback https://github.com/webpack/less-loader/issues/74" />
</changelist>
@@ -0,0 +1,27 @@
Index: test/index.test.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/index.test.js (revision 7ab6a2ef7d17e1ebaa9d15e8cf79fc0120c21523)
+++ test/index.test.js (revision )
@@ -29,6 +29,7 @@
}
});
test("should not try to resolve import urls", "imports-url");
+ test("should not try to resolve import urls", "imports-url");
test("should compile data-uri function", "data-uri");
test("should transform urls", "url-path");
test("should transform urls to files above the current directory", "folder/url-path");
Index: test/less/imports-fallback.less
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- test/less/imports-fallback.less (revision )
+++ test/less/imports-fallback.less (revision )
@@ -0,0 +1,4 @@
+// This import does not use a tilde to reference the bower_components folder just like your JS modules.
+// In this case, the less-loader will first try to resolve ./module.less and then module.less. This behavior is pretty
+// similar to how LESS is handling the --inlucde-path option
+@import "module.less";
+36
View File
@@ -0,0 +1,36 @@
Index: README.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- README.md (date 1425659589000)
+++ README.md (revision )
@@ -53,25 +53,15 @@
See the [LESS documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options. LESS translates dash-case to camelCase.
-## Note on imports
+## Imports
-webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The less-loader stubs less' `fileLoader` and passes all queries to the webpack resolving engine. Thus you can import your less-modules from `node_modules` or `bower_components`. Just prepend them with a `~` which tells webpack to look-up the [`modulesDirectories`](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories)
+webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The less-loader stubs less' `fileLoader` and passes all queries to the webpack resolving engine. Thus you can import your less-modules from `node_modules`. Just prepend them with a `~` which tells webpack to look-up the [`modulesDirectories`](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories)
```css
@import "~bootstrap/less/bootstrap";
```
-It's important to only prepend it with `~`, because `~/` resolves to the home-directory. webpack needs to distinguish `bootstrap` from `~bootstrap` because css- and less-files have no special syntax for importing relative files:
-
-```css
-@import "file";
-```
-
-is the same as
-
-```css
-@import "./file";
-```
+It's important to only prepend it with `~`, because `~/` resolves to the home-directory. webpack needs to distinguish between `bootstrap` and `~bootstrap` because css- and less-files have no special syntax for importing relative files. Writing `@import "file"` is the same as `@import "./file";`
## Source maps
+4
View File
@@ -0,0 +1,4 @@
<changelist name="tmp" date="1427063743490" recycled="true">
<option name="PATH" value="$PROJECT_DIR$/.idea/shelf/tmp.patch" />
<option name="DESCRIPTION" value="tmp" />
</changelist>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions" suppressed-tasks="Less" />
</project>
+2
View File
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4" />
+1245
View File
File diff suppressed because it is too large Load Diff
+48
View File
@@ -0,0 +1,48 @@
{
"browser": true,
"node": true,
"expr": true,
"predef": [ // Extra globals.
"describe",
"it",
"before",
"after",
"beforeEach",
"afterEach"
],
"curly": false, // Require {} for every new block or scope.
"eqeqeq": true, // Require triple equals i.e. `===`.
"forin": true, // Tolerate `for in` loops without `hasOwnPrototype`.
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef": false, // Prohibit variable use before definition.
"newcap": false, // Require capitalization of all constructor functions e.g. `new F()`.
"noempty": true, // Prohibit use of empty blocks.
"nonew": false, // Prohibit use of constructors for side-effects.
"plusplus": false, // Prohibit use of `++` & `--`.
"undef": true, // Require all non-global variables be declared before they are used.
"strict": true, // Require `use strict` pragma in every file.
"trailing": true, // Prohibit trailing whitespaces.
"asi": false, // Tolerate Automatic Semicolon Insertion (no semicolons).
"boss": false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
"debug": false, // Allow debugger statements e.g. browser breakpoints.
"eqnull": false, // Tolerate use of `== null`.
"esnext": false, // Allow ES.next specific features such as `const` and `let`.
"evil": false, // Tolerate use of `eval`.
"funcscope": false, // Tolerate declarations of variables inside of control structures while accessing them later from the outside.
"globalstrict": false, // Allow global "use strict" (also enables 'strict').
"iterator": false, // Allow usage of __iterator__ property.
"lastsemic": false, // Tolerat missing semicolons when the it is omitted for the last statement in a one-line block.
"laxbreak": false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
"laxcomma": false, // Suppress warnings about comma-first coding style.
"loopfunc": false, // Allow functions to be defined within loops.
"multistr": false, // Tolerate multi-line strings.
"quotmark": "double", // Only double quotes for strings.
"proto": false, // Tolerate __proto__ property. This property is deprecated.
"scripturl": false, // Tolerate script-targeted URLs.
"smarttabs": false, // Tolerate mixed tabs and spaces when the latter are used for alignmnent only.
"shadow": false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
"sub": true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
"supernew": false, // Tolerate `new function () { ... };` and `new Object;`.
"validthis": false // Tolerate strict violations when the code is running in strict mode and you use this in a non-constructor function
}
+1
View File
@@ -0,0 +1 @@
test/
+13
View File
@@ -0,0 +1,13 @@
sudo: false
language: node_js
node_js:
- "0.10"
- "0.11"
- "0.12"
- "4"
script:
- "npm test"
# test with npm@3
- "rm -rf node_modules && npm install npm@3"
- "node_modules/.bin/npm install"
- "node_modules/.bin/npm test"
+19
View File
@@ -0,0 +1,19 @@
Changelog
---------
### 2.2.3
- Fix missing path information in source map [#73](https://github.com/webpack/less-loader/pull/73)
- Add deprecation warning [#84](https://github.com/webpack/less-loader/issues/84)
### 2.2.2
- Fix issues with synchronous less functions like `data-uri()`, `image-size()`, `image-width()`, `image-height()` [#31](https://github.com/webpack/less-loader/issues/31) [#38](https://github.com/webpack/less-loader/issues/38) [#43](https://github.com/webpack/less-loader/issues/43) [#58](https://github.com/webpack/less-loader/pull/58)
### 2.2.1
- Improve Readme
### 2.2.0
- Added option to specify LESS plugins [#40](https://github.com/webpack/less-loader/pull/40)
+18
View File
@@ -0,0 +1,18 @@
Copyright (c) 2015 Tobias Koppers
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+132
View File
@@ -0,0 +1,132 @@
# less loader for webpack
## Installation
`npm install less-loader --save-dev`
## Usage
[Documentation: Using loaders](http://webpack.github.io/docs/using-loaders.html)
``` javascript
var css = require("!raw!less!./file.less");
// => returns compiled css code from file.less, resolves imports
var css = require("!css!less!./file.less");
// => returns compiled css code from file.less, resolves imports and url(...)s
```
Use in tandem with the [`style-loader`](https://github.com/webpack/style-loader) to add the css rules to your document:
``` javascript
require("!style!css!less!./file.less");
```
### webpack config
``` javascript
module.exports = {
module: {
loaders: [
{
test: /\.less$/,
loader: "style!css!less"
}
]
}
};
```
Then you only need to write: `require("./file.less")`
### LESS options
You can pass any LESS specific configuration options through to the render function via [query parameters](http://webpack.github.io/docs/using-loaders.html#query-parameters).
``` javascript
module.exports = {
module: {
loaders: [
{
test: /\.less$/,
loader: "style!css!less?strictMath&noIeCompat"
}
]
}
};
```
See the [LESS documentation](http://lesscss.org/usage/#command-line-usage-options) for all available options. LESS translates dash-case to camelCase. Certain options which take values (e.g. `lessc --modify-var="a=b"`) are better handled with the [JSON loader syntax](http://webpack.github.io/docs/using-loaders.html#query-parameters) (`style!css!less?{"modifyVars":{"a":"b"}}`).
### LESS plugins
In order to use [plugins](http://lesscss.org/usage/#plugins), simply set
the `lessLoader.lessPlugins`-option on your webpack options. You can also change the options' key with a query parameter: `"less?config=lessLoaderCustom"`.
``` javascript
var LessPluginCleanCSS = require('less-plugin-clean-css');
module.exports = {
...
lessLoader: {
lessPlugins: [
new LessPluginCleanCSS({advanced: true})
]
}
};
```
## Imports
webpack provides an [advanced mechanism to resolve files](http://webpack.github.io/docs/resolving.html). The less-loader stubs less' `fileLoader` and passes all queries to the webpack resolving engine. Thus you can import your less-modules from `node_modules`. Just prepend them with a `~` which tells webpack to look-up the [`modulesDirectories`](http://webpack.github.io/docs/configuration.html#resolve-modulesdirectories)
```css
@import "~bootstrap/less/bootstrap";
```
It's important to only prepend it with `~`, because `~/` resolves to the home-directory. webpack needs to distinguish between `bootstrap` and `~bootstrap` because css- and less-files have no special syntax for importing relative files. Writing `@import "file"` is the same as `@import "./file";`
## Source maps
Because of browser limitations, source maps are only available in conjunction with the [extract-text-webpack-plugin](https://github.com/webpack/extract-text-webpack-plugin). Use that plugin to extract the CSS code from the generated JS bundle into a separate file (which even improves the perceived performance because JS and CSS are loaded in parallel).
Then your `webpack.config.js` should look like this:
```javascript
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
...
// must be 'source-map' or 'inline-source-map'
devtool: 'source-map',
module: {
loaders: [
{
test: /\.less$/,
loader: ExtractTextPlugin.extract(
// activate source maps via loader query
'css?sourceMap!' +
'less?sourceMap'
)
}
]
},
plugins: [
// extract inline css into separate 'styles.css'
new ExtractTextPlugin('styles.css')
]
};
```
If you want to view the original LESS files inside Chrome and even edit it, [there's a good blog post](https://medium.com/@toolmantim/getting-started-with-css-sourcemaps-and-in-browser-sass-editing-b4daab987fb0). Checkout [test/sourceMap](https://github.com/webpack/less-loader/tree/master/test) for a running example. Make sure to serve the content with an HTTP server.
## Contribution
Don't hesitate to create a pull request. Every contribution is appreciated. In development you can start the tests by calling `npm test`.
The tests are basically just comparing the generated css with a reference css-file located under `test/css`. You can easily generate a reference css-file by calling `node test/helpers/generateCss.js <less-file-without-less-extension>`. It passes the less-file to less and writes the output to the `test/css`-folder.
[![build status](https://travis-ci.org/webpack/less-loader.svg)](https://travis-ci.org/webpack/less-loader)
## License
MIT (http://www.opensource.org/licenses/mit-license.php)
+172
View File
@@ -0,0 +1,172 @@
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Authors
Tobias Koppers @sokra
Johannes Ewald @jhnns
*/
var less = require("less");
var fs = require("fs");
var loaderUtils = require("loader-utils");
var path = require("path");
var util = require("util");
var trailingSlash = /[\\\/]$/;
module.exports = function(source) {
var loaderContext = this;
var query = loaderUtils.parseQuery(this.query);
var cb = this.async();
var isSync = typeof cb !== "function";
var finalCb = cb || this.callback;
var configKey = query.config || "lessLoader";
var config = {
filename: this.resource,
paths: [],
relativeUrls: true,
compress: !!this.minimize
};
var webpackPlugin = {
install: function(less, pluginManager) {
var WebpackFileManager = getWebpackFileManager(less, loaderContext, query, isSync);
pluginManager.addFileManager(new WebpackFileManager());
},
minVersion: [2, 1, 1]
};
this.cacheable && this.cacheable();
Object.keys(query).forEach(function(attr) {
config[attr] = query[attr];
});
// Now we're adding the webpack plugin, because there might have
// been added some before via query-options.
config.plugins = config.plugins || [];
config.plugins.push(webpackPlugin);
// If present, add custom LESS plugins.
if (this.options[configKey]) {
config.plugins = config.plugins.concat(this.options[configKey].lessPlugins || []);
}
// not using the `this.sourceMap` flag because css source maps are different
// @see https://github.com/webpack/css-loader/pull/40
if (query.sourceMap) {
config.sourceMap = {
outputSourceFiles: true
};
}
less.render(source, config, function(e, result) {
var cb = finalCb;
// Less is giving us double callbacks sometimes :(
// Thus we need to mark the callback as "has been called"
if(!finalCb) return;
finalCb = null;
if(e) return cb(formatLessRenderError(e));
cb(null, result.css, result.map);
});
};
function getWebpackFileManager(less, loaderContext, query, isSync) {
function WebpackFileManager() {
less.FileManager.apply(this, arguments);
}
WebpackFileManager.prototype = Object.create(less.FileManager.prototype);
WebpackFileManager.prototype.supports = function(filename, currentDirectory, options, environment) {
// Our WebpackFileManager handles all the files
return true;
};
WebpackFileManager.prototype.supportsSync = function(filename, currentDirectory, options, environment) {
return isSync;
};
WebpackFileManager.prototype.loadFile = function(filename, currentDirectory, options, environment, callback) {
// Unfortunately we don't have any influence on less to call `loadFile` or `loadFileSync`
// thus we need to decide for ourselves.
// @see https://github.com/less/less.js/issues/2325
if (isSync) {
try {
callback(null, this.loadFileSync(filename, currentDirectory, options, environment));
} catch (err) {
callback(err);
}
return;
}
var moduleRequest = loaderUtils.urlToRequest(filename, query.root);
// Less is giving us trailing slashes, but the context should have no trailing slash
var context = currentDirectory.replace(trailingSlash, "");
loaderContext.resolve(context, moduleRequest, function(err, filename) {
if(err) {
callback(err);
return;
}
loaderContext.dependency && loaderContext.dependency(filename);
// The default (asynchronous)
loaderContext.loadModule("-!" + __dirname + "/stringify.loader.js!" + filename, function(err, data) {
if(err) {
callback(err);
return;
}
callback(null, {
contents: JSON.parse(data),
filename: filename
});
});
});
};
WebpackFileManager.prototype.loadFileSync = util.deprecate(function(filename, currentDirectory, options, environment) {
var moduleRequest = loaderUtils.urlToRequest(filename, query.root);
// Less is giving us trailing slashes, but the context should have no trailing slash
var context = currentDirectory.replace(trailingSlash, "");
var data;
filename = loaderContext.resolveSync(context, moduleRequest);
loaderContext.dependency && loaderContext.dependency(filename);
data = fs.readFileSync(filename, "utf8");
return {
contents: data,
filename: filename
};
}, "We are planing to remove enhanced-require support with the next major release of the less-loader: https://github.com/webpack/less-loader/issues/84");
return WebpackFileManager;
}
function formatLessRenderError(e) {
// Example ``e``:
// { type: 'Name',
// message: '.undefined-mixin is undefined',
// filename: '/path/to/style.less',
// index: 352,
// line: 31,
// callLine: NaN,
// callExtract: undefined,
// column: 6,
// extract:
// [ ' .my-style {',
// ' .undefined-mixin;',
// ' display: block;' ] }
var extract = e.extract? "\n near lines:\n " + e.extract.join("\n ") : "";
var err = new Error(
e.message + "\n @ " + e.filename +
" (line " + e.line + ", column " + e.column + ")" +
extract
);
err.hideStack = true;
return err;
}
+106
View File
@@ -0,0 +1,106 @@
{
"_args": [
[
{
"raw": "less-loader@^2.2.3",
"scope": null,
"escapedName": "less-loader",
"name": "less-loader",
"rawSpec": "^2.2.3",
"spec": ">=2.2.3 <3.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\laravel-mix"
]
],
"_from": "less-loader@>=2.2.3 <3.0.0",
"_id": "less-loader@2.2.3",
"_inCache": true,
"_location": "/less-loader",
"_nodeVersion": "5.9.1",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/less-loader-2.2.3.tgz_1458935338853_0.0017933058552443981"
},
"_npmUser": {
"name": "jhnns",
"email": "mail@johannesewald.de"
},
"_npmVersion": "3.7.3",
"_phantomChildren": {},
"_requested": {
"raw": "less-loader@^2.2.3",
"scope": null,
"escapedName": "less-loader",
"name": "less-loader",
"rawSpec": "^2.2.3",
"spec": ">=2.2.3 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/less-loader/-/less-loader-2.2.3.tgz",
"_shasum": "b6d8f8139c8493df09d992a93a00734b08f84528",
"_shrinkwrap": null,
"_spec": "less-loader@^2.2.3",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\laravel-mix",
"author": {
"name": "Tobias Koppers @sokra"
},
"bugs": {
"url": "https://github.com/webpack/less-loader/issues"
},
"dependencies": {
"loader-utils": "^0.2.5"
},
"description": "less loader module for webpack",
"devDependencies": {
"css-loader": "^0.23.1",
"enhanced-require": "^0.5.0-beta6",
"extract-text-webpack-plugin": "^1.0.1",
"less": "^2.6.1",
"mocha": "^2.4.5",
"raw-loader": "^0.5.1",
"should": "^8.3.0",
"webpack": "^1.12.14"
},
"directories": {},
"dist": {
"shasum": "b6d8f8139c8493df09d992a93a00734b08f84528",
"tarball": "https://registry.npmjs.org/less-loader/-/less-loader-2.2.3.tgz"
},
"gitHead": "7f0fd0fb7baabebbeaadb9507896bdc0438030b5",
"homepage": "https://github.com/webpack/less-loader#readme",
"licenses": [
{
"type": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
}
],
"maintainers": [
{
"name": "sokra",
"email": "tobias.koppers@googlemail.com"
},
{
"name": "jhnns",
"email": "mail@johannesewald.de"
}
],
"name": "less-loader",
"optionalDependencies": {},
"peerDependencies": {
"less": "^2.3.1"
},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/webpack/less-loader.git"
},
"scripts": {
"test": "node --no-deprecation node_modules/.bin/_mocha -R spec",
"test-source-map": "webpack --config test/sourceMap/webpack.config.js && open ./test/sourceMap/index.html"
},
"version": "2.2.3"
}
+8
View File
@@ -0,0 +1,8 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(source) {
if(this.cacheable) this.cacheable();
return JSON.stringify(source);
};