Skip to content

Make images smaller using best-in-class codecs, right in the browser.

JavaScript

Fix windows builds breaking due to mixed paths

Jason Millercf1a71853400
diff --git a/config/add-css-types.js b/config/add-css-types.js
index fcfeab01..97ef9a11 100644
--- a/config/add-css-types.js
+++ b/config/add-css-types.js
@@ -2,6 +2,7 @@ const DtsCreator = require('typed-css-modules');
const chokidar = require('chokidar');
const util = require('util');
const sass = require('node-sass');
+const normalizePath = require('normalize-path');
const sassRender = util.promisify(sass.render);
@@ -29,9 +30,10 @@ function addCssTypes(rootPaths, opts = {}) {
let ready = false;
for (const rootPath of rootPaths) {
+ const rootPathUnix = normalizePath(rootPath);
// Look for scss & css in each path.
- paths.push(rootPath + '/**/*.scss');
- paths.push(rootPath + '/**/*.css');
+ paths.push(rootPathUnix + '/**/*.scss');
+ paths.push(rootPathUnix + '/**/*.css');
}
// For simplicity, the watcher is used even if we're not watching.
@@ -68,7 +70,7 @@ function addCssTypes(rootPaths, opts = {}) {
// And if we're not watching, close the watcher.
if (!watch) watcher.close();
});
- })
+ });
}
module.exports = addCssTypes;
diff --git a/package-lock.json b/package-lock.json
index 63426a05..f113c6b6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1775,6 +1775,17 @@
"requires": {
"micromatch": "^3.1.4",
"normalize-path": "^2.1.1"
+ },
+ "dependencies": {
+ "normalize-path": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
+ "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
+ "dev": true,
+ "requires": {
+ "remove-trailing-separator": "^1.0.1"
+ }
+ }
}
},
"aproba": {
@@ -9953,13 +9964,10 @@
}
},
"normalize-path": {
- "version": "2.1.1",
- "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
- "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
- "dev": true,
- "requires": {
- "remove-trailing-separator": "^1.0.1"
- }
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
+ "dev": true
},
"normalize-url": {
"version": "2.0.1",
diff --git a/package.json b/package.json
index cc76ca3f..30e5635f 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,7 @@
"minimatch": "3.0.4",
"node-fetch": "2.6.0",
"node-sass": "4.13.0",
+ "normalize-path": "^3.0.0",
"optimize-css-assets-webpack-plugin": "5.0.1",
"pointer-tracker": "2.0.3",
"preact": "8.4.2",
diff --git a/webpack.config.js b/webpack.config.js
index 1b840520..3b31bfc6 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -22,10 +22,10 @@ module.exports = async function (_, env) {
const isProd = env.mode === 'production';
const nodeModules = path.join(__dirname, 'node_modules');
const componentStyleDirs = [
- path.join(__dirname, 'src/components'),
- path.join(__dirname, 'src/codecs'),
- path.join(__dirname, 'src/custom-els'),
- path.join(__dirname, 'src/lib'),
+ path.join(__dirname, 'src', 'components'),
+ path.join(__dirname, 'src', 'codecs'),
+ path.join(__dirname, 'src', 'custom-els'),
+ path.join(__dirname, 'src', 'lib')
];
await addCssTypes(componentStyleDirs, { watch: !isProd });
@@ -53,7 +53,7 @@ module.exports = async function (_, env) {
resolveLoader: {
alias: {
// async-component-loader returns a wrapper component that waits for the import to load before rendering:
- async: path.join(__dirname, 'config/async-component-loader')
+ async: path.join(__dirname, 'config', 'async-component-loader')
}
},
module: {
@@ -143,7 +143,7 @@ module.exports = async function (_, env) {
{
// All the codec files define a global with the same name as their file name. `exports-loader` attaches those to `module.exports`.
test: /\.js$/,
- include: path.join(__dirname, 'src/codecs'),
+ include: path.join(__dirname, 'src', 'codecs'),
loader: 'exports-loader'
},
{