mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 18:49:50 +00:00
Merge branch 'dev' into consolidate-rust
This commit is contained in:
@@ -2,6 +2,7 @@ const DtsCreator = require('typed-css-modules');
|
|||||||
const chokidar = require('chokidar');
|
const chokidar = require('chokidar');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const sass = require('node-sass');
|
const sass = require('node-sass');
|
||||||
|
const normalizePath = require('normalize-path');
|
||||||
|
|
||||||
const sassRender = util.promisify(sass.render);
|
const sassRender = util.promisify(sass.render);
|
||||||
|
|
||||||
@@ -29,9 +30,10 @@ function addCssTypes(rootPaths, opts = {}) {
|
|||||||
let ready = false;
|
let ready = false;
|
||||||
|
|
||||||
for (const rootPath of rootPaths) {
|
for (const rootPath of rootPaths) {
|
||||||
|
const rootPathUnix = normalizePath(rootPath);
|
||||||
// Look for scss & css in each path.
|
// Look for scss & css in each path.
|
||||||
paths.push(rootPath + '/**/*.scss');
|
paths.push(rootPathUnix + '/**/*.scss');
|
||||||
paths.push(rootPath + '/**/*.css');
|
paths.push(rootPathUnix + '/**/*.css');
|
||||||
}
|
}
|
||||||
|
|
||||||
// For simplicity, the watcher is used even if we're not watching.
|
// 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.
|
// And if we're not watching, close the watcher.
|
||||||
if (!watch) watcher.close();
|
if (!watch) watcher.close();
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = addCssTypes;
|
module.exports = addCssTypes;
|
||||||
|
|||||||
22
package-lock.json
generated
22
package-lock.json
generated
@@ -1775,6 +1775,17 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"micromatch": "^3.1.4",
|
"micromatch": "^3.1.4",
|
||||||
"normalize-path": "^2.1.1"
|
"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": {
|
"aproba": {
|
||||||
@@ -9953,13 +9964,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"normalize-path": {
|
"normalize-path": {
|
||||||
"version": "2.1.1",
|
"version": "3.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
|
||||||
"integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=",
|
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
|
||||||
"dev": true,
|
"dev": true
|
||||||
"requires": {
|
|
||||||
"remove-trailing-separator": "^1.0.1"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"normalize-url": {
|
"normalize-url": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
"minimatch": "3.0.4",
|
"minimatch": "3.0.4",
|
||||||
"node-fetch": "2.6.0",
|
"node-fetch": "2.6.0",
|
||||||
"node-sass": "4.13.0",
|
"node-sass": "4.13.0",
|
||||||
|
"normalize-path": "^3.0.0",
|
||||||
"optimize-css-assets-webpack-plugin": "5.0.1",
|
"optimize-css-assets-webpack-plugin": "5.0.1",
|
||||||
"pointer-tracker": "2.0.3",
|
"pointer-tracker": "2.0.3",
|
||||||
"preact": "8.4.2",
|
"preact": "8.4.2",
|
||||||
|
|||||||
@@ -18,14 +18,15 @@ const addCssTypes = require('./config/add-css-types');
|
|||||||
|
|
||||||
const VERSION = require('./package.json').version;
|
const VERSION = require('./package.json').version;
|
||||||
|
|
||||||
module.exports = async function (_, env) {
|
/** @returns {Promise<import('webpack').Configuration>} */
|
||||||
|
module.exports = async function(_, env) {
|
||||||
const isProd = env.mode === 'production';
|
const isProd = env.mode === 'production';
|
||||||
const nodeModules = path.join(__dirname, 'node_modules');
|
const nodeModules = path.join(__dirname, 'node_modules');
|
||||||
const componentStyleDirs = [
|
const componentStyleDirs = [
|
||||||
path.join(__dirname, 'src/components'),
|
path.join(__dirname, 'src', 'components'),
|
||||||
path.join(__dirname, 'src/codecs'),
|
path.join(__dirname, 'src', 'codecs'),
|
||||||
path.join(__dirname, 'src/custom-els'),
|
path.join(__dirname, 'src', 'custom-els'),
|
||||||
path.join(__dirname, 'src/lib'),
|
path.join(__dirname, 'src', 'lib')
|
||||||
];
|
];
|
||||||
|
|
||||||
await addCssTypes(componentStyleDirs, { watch: !isProd });
|
await addCssTypes(componentStyleDirs, { watch: !isProd });
|
||||||
@@ -53,18 +54,17 @@ module.exports = async function (_, env) {
|
|||||||
resolveLoader: {
|
resolveLoader: {
|
||||||
alias: {
|
alias: {
|
||||||
// async-component-loader returns a wrapper component that waits for the import to load before rendering:
|
// 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: {
|
module: {
|
||||||
// Disable the default JavaScript handling:
|
|
||||||
defaultRules: [],
|
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{
|
{
|
||||||
test: /(\.mjs|\.esm\.js)$/i,
|
test: /(\.mjs|\.esm\.js)$/i,
|
||||||
type: 'javascript/esm',
|
// don't use strict esm resolution for mjs:
|
||||||
|
type: 'javascript/auto',
|
||||||
resolve: {},
|
resolve: {},
|
||||||
parser: {
|
parser: {
|
||||||
harmony: true,
|
harmony: true,
|
||||||
@@ -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`.
|
// All the codec files define a global with the same name as their file name. `exports-loader` attaches those to `module.exports`.
|
||||||
test: /\.js$/,
|
test: /\.js$/,
|
||||||
include: path.join(__dirname, 'src/codecs'),
|
include: path.join(__dirname, 'src', 'codecs'),
|
||||||
loader: 'exports-loader'
|
loader: 'exports-loader'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -183,6 +183,7 @@ module.exports = async function (_, env) {
|
|||||||
format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m\r',
|
format: '\u001b[90m\u001b[44mBuild\u001b[49m\u001b[39m [:bar] \u001b[32m\u001b[1m:percent\u001b[22m\u001b[39m (:elapseds) \u001b[2m:msg\u001b[22m\r',
|
||||||
renderThrottle: 100,
|
renderThrottle: 100,
|
||||||
summary: false,
|
summary: false,
|
||||||
|
total: 10,
|
||||||
clear: true
|
clear: true
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -198,10 +199,6 @@ module.exports = async function (_, env) {
|
|||||||
|
|
||||||
new WorkerPlugin(),
|
new WorkerPlugin(),
|
||||||
|
|
||||||
// Automatically split code into async chunks.
|
|
||||||
// See: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
|
||||||
isProd && new webpack.optimize.SplitChunksPlugin({}),
|
|
||||||
|
|
||||||
// In production, extract all CSS to produce files on disk, even for
|
// In production, extract all CSS to produce files on disk, even for
|
||||||
// lazy-loaded CSS chunks. CSS for async chunks is loaded on-demand.
|
// lazy-loaded CSS chunks. CSS for async chunks is loaded on-demand.
|
||||||
// This is a modern Webpack 4 replacement for ExtractTextPlugin.
|
// This is a modern Webpack 4 replacement for ExtractTextPlugin.
|
||||||
@@ -302,6 +299,10 @@ module.exports = async function (_, env) {
|
|||||||
].filter(Boolean), // Filter out any falsey plugin array entries.
|
].filter(Boolean), // Filter out any falsey plugin array entries.
|
||||||
|
|
||||||
optimization: {
|
optimization: {
|
||||||
|
splitChunks: {
|
||||||
|
// Automatically split code into async chunks.
|
||||||
|
// See: https://medium.com/webpack/webpack-4-code-splitting-chunk-graph-and-the-splitchunks-optimization-be739a861366
|
||||||
|
},
|
||||||
minimizer: [
|
minimizer: [
|
||||||
new TerserPlugin({
|
new TerserPlugin({
|
||||||
sourceMap: isProd,
|
sourceMap: isProd,
|
||||||
|
|||||||
Reference in New Issue
Block a user