Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken assetsDir due to updated copy-webpack-plugin #1690

Merged
merged 3 commits into from Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 28 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -38,7 +38,7 @@
"clipboard-copy": "^3.1.0",
"clsx": "^1.0.4",
"common-dir": "^3.0.0",
"copy-webpack-plugin": "^6.0.3",
"copy-webpack-plugin": "^6.1.0",
"core-js": "^3.6.4",
"doctrine": "^3.0.0",
"es6-object-assign": "~1.1.0",
Expand Down Expand Up @@ -106,7 +106,7 @@
"@testing-library/jest-dom": "^5.3.0",
"@testing-library/react": "^10.0.1",
"@types/buble": "^0.19.2",
"@types/copy-webpack-plugin": "^5.0.0",
"@types/copy-webpack-plugin": "^5.0.2",
"@types/doctrine": "0.0.3",
"@types/enzyme": "^3.10.3",
"@types/escodegen": "0.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/utils/__tests__/highlightCode.spec.ts
Expand Up @@ -17,7 +17,7 @@ it('should warn when language not found', () => {
const actual = highlightCode(code, 'pizza');
expect(actual).toBe(code);
expect(warn).toBeCalledWith(
'Syntax highlighting for “pizza” isn’t supported. Supported languages are: markup, xml, html, mathml, svg, css, clike, javascript, js, markdown, md, scss, less, flow, typescript, ts, jsx, tsx, graphql, json, bash, shell, diff.'
'Syntax highlighting for “pizza” isn’t supported. Supported languages are: markup, html, mathml, svg, xml, ssml, atom, rss, css, clike, javascript, js, markdown, md, scss, less, flow, typescript, ts, jsx, tsx, graphql, json, webmanifest, bash, shell, diff.'
);
});

Expand Down
8 changes: 6 additions & 2 deletions src/scripts/__tests__/make-webpack-config.spec.ts
Expand Up @@ -117,12 +117,16 @@ it('should enable verbose mode in CleanWebpackPlugin', () => {

it('should set from with assetsDir in CopyWebpackPlugin', () => {
makeWebpackConfig({ ...styleguideConfig, assetsDir: '/assets/' }, 'production');
expect(CopyWebpackPlugin).toHaveBeenCalledWith([{ from: '/assets/' }]); //([
expect(CopyWebpackPlugin).toHaveBeenCalledWith({
patterns: [{ from: '/assets/' }],
});
});

it('should set array of from with assetsDir array in CopyWebpackPlugin', () => {
makeWebpackConfig({ ...styleguideConfig, assetsDir: ['/assets1/', '/assets2/'] }, 'production');
expect(CopyWebpackPlugin).toHaveBeenCalledWith([{ from: '/assets1/' }, { from: '/assets2/' }]);
expect(CopyWebpackPlugin).toHaveBeenCalledWith({
patterns: [{ from: '/assets1/' }, { from: '/assets2/' }],
});
});

it('should merge user webpack config', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/scripts/make-webpack-config.ts
Expand Up @@ -108,8 +108,14 @@ export default function(
},
});
if (config.assetsDir && webpackConfig.plugins) {
const copyPatterns = {
patterns: castArray(config.assetsDir).map(dir => ({ from: dir })),
};
webpackConfig.plugins.push(
new CopyWebpackPlugin(castArray(config.assetsDir).map(dir => ({ from: dir })))
// FIXME: Since we don't have the type of copy-webpack-plugin@6.0
// we cast the config as any to make it work. Once the new types are
// released we must remove the cast.
new CopyWebpackPlugin(copyPatterns as any)
);
}
} else {
Expand Down