mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-04-18 14:00:59 +00:00
Fix static asset building on Windows
Normalize all paths to have only forward slashes before mangling them.
This commit is contained in:
parent
62b996622a
commit
6f18c5ea0f
3 changed files with 18 additions and 3 deletions
13
gulpfile.js/lib/normalize-path.js
Normal file
13
gulpfile.js/lib/normalize-path.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
var quoteRegExp = function (str) {
|
||||
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&");
|
||||
};
|
||||
var re = new RegExp(quoteRegExp(require("path").sep), "g");
|
||||
|
||||
/**
|
||||
* Normalize path separators to forward slashes
|
||||
* @param path A path in either Windows or POSIX format
|
||||
* @returns {string} A path in POSIX format
|
||||
*/
|
||||
module.exports = function (path) {
|
||||
return ("" + path).replace(re, "/");
|
||||
};
|
||||
|
|
@ -3,6 +3,7 @@ var rename = require('gulp-rename');
|
|||
var gutil = require('gulp-util');
|
||||
var path = require('path');
|
||||
var config = require('../config');
|
||||
var normalizePath = require('../lib/normalize-path');
|
||||
|
||||
/*
|
||||
* Simple copy task - just copoes files from the source to the destination,
|
||||
|
|
@ -12,7 +13,7 @@ var config = require('../config');
|
|||
|
||||
var renameSrcToDest = function() {
|
||||
return rename(function(filePath) {
|
||||
filePath.dirname = filePath.dirname.replace(
|
||||
filePath.dirname = normalizePath(filePath.dirname).replace(
|
||||
'/' + config.srcDir + '/',
|
||||
'/' + config.destDir + '/');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ var sass = require('gulp-sass');
|
|||
var config = require('../config');
|
||||
var autoprefixer = require('gulp-autoprefixer');
|
||||
var simpleCopyTask = require('../lib/simplyCopy');
|
||||
var normalizePath = require('../lib/normalize-path');
|
||||
var gutil = require('gulp-util');
|
||||
|
||||
var flatten = function(arrOfArr) {
|
||||
|
|
@ -38,9 +39,9 @@ gulp.task('styles:sass', function () {
|
|||
.pipe(gulp.dest(function(file) {
|
||||
// e.g. wagtailadmin/scss/core.scss -> wagtailadmin/css/core.css
|
||||
// Changing the suffix is done by Sass automatically
|
||||
return file.base
|
||||
return normalizePath(file.base)
|
||||
.replace(
|
||||
'/' + config.srcDir + '/',
|
||||
'/' + config.srcDir + '/',
|
||||
'/' + config.destDir + '/'
|
||||
)
|
||||
.replace('/scss/', '/css/');
|
||||
|
|
|
|||
Loading…
Reference in a new issue