Skip to content

Commit 32bf054

Browse files
committed
fix(tooling): Copy non-js files correctly on build
1 parent c2f9369 commit 32bf054

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"build:components": "npm run build components",
1010
"build:packagejson": "npm run build package.json",
1111
"build:widgets": "npm run build widgets",
12-
"clean": "npm run clean:snapshots && npm run clean:dist && npm run clean:transpile",
13-
"clean:snapshots": "rimraf \"packages/**/__snapshots__/\"",
12+
"clean": "npm run clean:dist && npm run clean:transpile",
1413
"clean:dist": "rimraf \"packages/**/dist/\"",
1514
"clean:transpile": "rimraf \"packages/**/es/\" && rimraf \"packages/**/cjs/\"",
1615
"test": "npm run static-analysis && npm run jest",

scripts/utils/build.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ function buildFile(filename, destination, babelOptions = {}) {
101101
const ext = path.extname(filename);
102102
const outputPath = path.join(destination, path.basename(filename));
103103
// Ignore non-JS files and test scripts
104-
if (ext === `.js` && !filename.includes(`.test.`)) {
105-
babelOptions.filename = filename;
106-
const result = transform(content, babelOptions);
107-
return outputFileSync(outputPath, result.code, {encoding: `utf8`});
108-
}
109-
// copy if it's a css file
110-
else if (ext === `.css`) {
111-
return execSync(`postcss ${filename} -o ${outputPath}`);
104+
if (!filename.includes(`.test.`)) {
105+
if (ext === `.js`) {
106+
babelOptions.filename = filename;
107+
const result = transform(content, babelOptions);
108+
return outputFileSync(outputPath, result.code, {encoding: `utf8`});
109+
}
110+
// process with postcss if it's a css file
111+
else if (ext === `.css`) {
112+
return execSync(`postcss ${filename} -o ${outputPath}`);
113+
}
114+
// Copy if it's any other type of file
115+
return outputFileSync(outputPath, content);
112116
}
113117
return false;
114118
}

0 commit comments

Comments
 (0)