Skip to content

Commit

Permalink
Fix build on Windows (GoogleChromeLabs#666)
Browse files Browse the repository at this point in the history
* 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 GoogleChromeLabs#465.
  • Loading branch information
RReverser authored and jakearchibald committed Jul 31, 2019
1 parent 94c50a9 commit 78da9fd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const CleanPlugin = require('clean-webpack-plugin');
Expand All @@ -17,11 +16,7 @@ const CrittersPlugin = require('critters-webpack-plugin');
const AssetTemplatePlugin = require('./config/asset-template-plugin');
const addCssTypes = require('./config/add-css-types');

function readJson (filename) {
return JSON.parse(fs.readFileSync(filename));
}

const VERSION = readJson('./package.json').version;
const VERSION = require('./package.json').version;

module.exports = async function (_, env) {
const isProd = env.mode === 'production';
Expand Down Expand Up @@ -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`.
test: /\/codecs\/.*\.js$/,
test: /\.js$/,
include: path.join(__dirname, 'src/codecs'),
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.
// See https://github.com/webpack/webpack/issues/6725
type: 'javascript/auto',
Expand All @@ -172,7 +169,7 @@ module.exports = async function (_, env) {
plugins: [
new webpack.IgnorePlugin(
/(fs|crypto|path)/,
new RegExp(`${path.sep}codecs${path.sep}`)
/[/\\]codecs[/\\]/
),

// Pretty progressbar showing build progress:
Expand Down Expand Up @@ -239,7 +236,7 @@ module.exports = async function (_, env) {
removeRedundantAttributes: true,
removeComments: true
},
manifest: readJson('./src/manifest.json'),
manifest: require('./src/manifest.json'),
inject: 'body',
compile: true
}),
Expand Down

0 comments on commit 78da9fd

Please sign in to comment.