Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
chore(demos): Remove env var and ignore import-only Sass files
Browse files Browse the repository at this point in the history
- The MDC_GENERATE_DEMO_THEMES env var is no longer needed after #1886
- Avoid creating Webpack entries for demo Sass files that are import-only (i.e., their filename starts with an underscore)
- Rename local variable for clarity
  • Loading branch information
acdvorak committed Jan 9, 2018
1 parent 302349e commit c8bd19f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ const GENERATE_SOURCE_MAPS =
process.env.MDC_GENERATE_SOURCE_MAPS === 'true' ||
(process.env.MDC_GENERATE_SOURCE_MAPS !== 'false' && IS_DEV && WRAP_CSS_IN_JS);
const DEVTOOL = GENERATE_SOURCE_MAPS ? 'source-map' : false;
const GENERATE_DEMO_THEMES = process.env.MDC_GENERATE_DEMO_THEMES !== 'false' && IS_DEV;
const BUILD_STATIC_DEMO_ASSETS = process.env.MDC_BUILD_STATIC_DEMO_ASSETS === 'true';

const banner = [
Expand Down Expand Up @@ -275,14 +274,19 @@ if (!IS_DEV) {

if (IS_DEV) {
const demoStyleEntry = {};
const exceptions = {};
if (!GENERATE_DEMO_THEMES) {
exceptions['demos/theme/index.scss'] = true;
}
glob.sync('demos/**/*.scss').forEach((filename) => {
if (!exceptions[filename]) {
demoStyleEntry[filename.slice(6, -5)] = path.resolve(filename);
glob.sync('demos/**/*.scss').forEach((relativeFilePath) => {
const filename = path.basename(relativeFilePath);

// Ignore import-only Sass files.
if (filename.charAt(0) === '_') {
return;
}

// The Webpack entry key for each Sass file is the relative path of the file with its leading "demo/" and trailing
// ".scss" affixes removed.
// E.g., "demos/foo/bar.scss" becomes {"foo/bar": "/absolute/path/to/demos/foo/bar.scss"}.
const entryName = relativeFilePath.replace(new RegExp('^demos/|\\.scss$', 'g'), '');
demoStyleEntry[entryName] = path.resolve(relativeFilePath);
});

module.exports.push({
Expand Down

0 comments on commit c8bd19f

Please sign in to comment.