Drupal Design Themes - NCIOCPL/cgov-digital-platform GitHub Wiki

Theme Design

File Structure

  • profiles
    • custom
      • cgov_base
        • themes
          • cgov_common - Theme common to all CancerGov Digital Platform sites
            • dist - The build process places the built css & js files into this folder for use in library configuration. This directory is untracked by source control.
              • js -
                • article.js
                • ...
              • css -
                • article.css
                • ...
            • src - Pre-built files. This should be removed from the final deployment artifact. (So if you need anything from here, it better get placed in dist.
              • main - Top-level publishable CSS and JS files. These are the "entry points" defined in the webpack config.
                • article - The Article content type.
                  • article.js - The Page Level JS file
                  • article.scss - The Page Level CSS file
                • ...
              • modules - Reusable & shared modules
                • accordion - Accordion module
                  • _accordion.scss
                  • accordion.js
                • ...
            • templates - Drupal templates
            • cgov_common.info.yml
            • webpack.js - Main webpack
      • www_profile - www.cancer.gov specific profile??
        • themes
          • cgov_www - www.cancer.gov theme
            • dist - The build process places the built css & js files into this folder for use in library configuration. This directory is untracked by source control.
              • js
                • article.js
                • pdq_summary.js
                • ...
              • css
                • article.css
                • pdq_summary.css
                • ...
            • src - Pre-built files. This should be removed from the final deployment artifact. (So if you need anything from here, it better get placed in dist.
              • main - Top-level publishable CSS and JS files. These are the "entry points" defined in the webpack config. This should only contain those entry points unique to this theme.
                • pdq_summary - The Article content type.
                  • pdq_summary.js -
                  • pdq_summary.scss -
              • modules - Reusable & shared modules
                • ...
            • templates - Drupal templates
            • cgov_www.info.yml
            • webpack.config.js - www webpack

Example webpacks

cgov_common Theme

module.exports = {
	context: path.resolve(__dirname, "src"),
	entry: {
          'article': path.resolve(__dirname, 'src/main/article'),
        },
        resolve: {
          modules: [
            //Assumption that the paths will have absolute paths if
            //modules array were inspected. 
            path.resolve(__dirname, 'src/modules'),
            path.resolve(__dirname, 'src/main'),
            path.resolve(__dirname, 'node_modules')
          ] 
        }
}

cgov_www Theme

const parentConfig = require(path.join(__dirname, '../../../cgov_base/themes/cgov_common/webpack.config.js'));
module.exports = {
	context: path.resolve(__dirname, "src"),
	entry: {
          ...parentConfig.exports.entry,
          'pdq_summary': './src/main/pdq_summary'
        },
        resolve: {
          modules: [
            ...parentConfig.resolve.modules,
            path.resolve(__dirname, 'src/modules'),
            path.resolve(__dirname, 'src/main'),
            path.resolve(__dirname, 'node_modules'),            
          ] 
        }
}
⚠️ **GitHub.com Fallback** ⚠️