Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,27 @@ module.exports = function (webpackEnv) {
},
].filter(Boolean);
if (preProcessor) {
/**
* NCIDS CSS requires compiling your Sass with load paths using
* dart-sass. Load paths must include a path to the `/packages`
* directory for NCIDS packages and `/uswds-packages` for USWDS
* packages.
*
* https://sass-lang.com/documentation/at-rules/use#load-paths
*/
const processorOpts =
preProcessor === 'sass-loader'
? {
sassOptions: {
includePaths: [path.join(__dirname, '../node_modules/@nciocpl/ncids-css/packages'), path.join(__dirname, '../node_modules/@nciocpl/ncids-css/uswds-packages')],
},
}
: {};
loaders.push({
loader: require.resolve(preProcessor),
options: {
sourceMap: true,
...processorOpts,
},
});
}
Expand Down Expand Up @@ -122,6 +139,7 @@ module.exports = function (webpackEnv) {
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
path.join(__dirname, '../src/digitalPlatformMockWrapper.js'),
].filter(Boolean),
output: {
// The build folder.
Expand Down Expand Up @@ -276,8 +294,6 @@ module.exports = function (webpackEnv) {
module: {
strictExportPresence: true,
rules: [
// Disable require.ensure as it's not a standard language feature.
{ parser: { requireEnsure: false } },
{
test: /\.m?js/,
resolve: {
Expand All @@ -304,6 +320,21 @@ module.exports = function (webpackEnv) {
filename: 'static/media/[name].[ext]',
},
},
// NCIDS/USWDS Sprites (assume other svgs that actually exist)
{
test: /\.svg$/,
// Temporarily let's inline these things.
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: imageInlineSizeLimit,
//mimetype: 'svg+xml',
},
},
],
include: [path.join(__dirname, '../node_modules/@nciocpl/ncids-css/uswds-img')],
},
// Process application JS with Babel.
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
{
Expand Down Expand Up @@ -398,6 +429,7 @@ module.exports = function (webpackEnv) {
test: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
url: true,
sourceMap: isEnvProduction && shouldUseSourceMap,
modules: {
getLocalIdent: getCSSModuleLocalIdent,
Expand All @@ -414,6 +446,7 @@ module.exports = function (webpackEnv) {
{
importLoaders: 3,
sourceMap: isEnvProduction && shouldUseSourceMap,
url: true,
},
'sass-loader'
),
Expand All @@ -431,6 +464,7 @@ module.exports = function (webpackEnv) {
{
importLoaders: 3,
sourceMap: isEnvProduction && shouldUseSourceMap,
url: true,
modules: {
getLocalIdent: getCSSModuleLocalIdent,
},
Expand Down
Loading