mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 18:19:47 +00:00
Fix build on Windows (#666)
* Use `require` for reading JSON JSON is natively supported by Node.js, so no point in using a custom helper here. * Fix build on Windows Fixes #465.
This commit is contained in:
committed by
Jake Archibald
parent
94c50a989b
commit
78da9fd144
@@ -1,4 +1,3 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const CleanPlugin = require('clean-webpack-plugin');
|
const CleanPlugin = require('clean-webpack-plugin');
|
||||||
@@ -17,11 +16,7 @@ const CrittersPlugin = require('critters-webpack-plugin');
|
|||||||
const AssetTemplatePlugin = require('./config/asset-template-plugin');
|
const AssetTemplatePlugin = require('./config/asset-template-plugin');
|
||||||
const addCssTypes = require('./config/add-css-types');
|
const addCssTypes = require('./config/add-css-types');
|
||||||
|
|
||||||
function readJson (filename) {
|
const VERSION = require('./package.json').version;
|
||||||
return JSON.parse(fs.readFileSync(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
const VERSION = readJson('./package.json').version;
|
|
||||||
|
|
||||||
module.exports = async function (_, env) {
|
module.exports = async function (_, env) {
|
||||||
const isProd = env.mode === 'production';
|
const isProd = env.mode === 'production';
|
||||||
@@ -147,11 +142,13 @@ 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: /\/codecs\/.*\.js$/,
|
test: /\.js$/,
|
||||||
|
include: path.join(__dirname, 'src/codecs'),
|
||||||
loader: 'exports-loader'
|
loader: 'exports-loader'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
test: /\/codecs\/.*\.wasm$/,
|
// For some reason using `include` here breaks the build.
|
||||||
|
test: /[/\\]codecs[/\\].*\.wasm$/,
|
||||||
// This is needed to make webpack NOT process wasm files.
|
// This is needed to make webpack NOT process wasm files.
|
||||||
// See https://github.com/webpack/webpack/issues/6725
|
// See https://github.com/webpack/webpack/issues/6725
|
||||||
type: 'javascript/auto',
|
type: 'javascript/auto',
|
||||||
@@ -172,7 +169,7 @@ module.exports = async function (_, env) {
|
|||||||
plugins: [
|
plugins: [
|
||||||
new webpack.IgnorePlugin(
|
new webpack.IgnorePlugin(
|
||||||
/(fs|crypto|path)/,
|
/(fs|crypto|path)/,
|
||||||
new RegExp(`${path.sep}codecs${path.sep}`)
|
/[/\\]codecs[/\\]/
|
||||||
),
|
),
|
||||||
|
|
||||||
// Pretty progressbar showing build progress:
|
// Pretty progressbar showing build progress:
|
||||||
@@ -239,7 +236,7 @@ module.exports = async function (_, env) {
|
|||||||
removeRedundantAttributes: true,
|
removeRedundantAttributes: true,
|
||||||
removeComments: true
|
removeComments: true
|
||||||
},
|
},
|
||||||
manifest: readJson('./src/manifest.json'),
|
manifest: require('./src/manifest.json'),
|
||||||
inject: 'body',
|
inject: 'body',
|
||||||
compile: true
|
compile: true
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user