-
-
Notifications
You must be signed in to change notification settings - Fork 377
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
refactor: Determine CSS module by filename, not directory #1714
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
dc9f0e4
refactor: Determine CSS module by filename, not directory
rschristian 778d782
docs: Adding changeset
rschristian 6036804
refactor: Project creation pull from templates 'main' branch
rschristian 1f48325
test: Updating tests
rschristian 8c5c4c7
revert: Accidentally removed log message
rschristian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ function getSassConfiguration(...includePaths) { | |
* @returns {import('webpack').Configuration} | ||
*/ | ||
module.exports = function createBaseConfig(env) { | ||
const { cwd, isProd, isWatch, src, source } = env; | ||
const { cwd, isProd, src, source } = env; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a consistency thing. Easier to scan if we're not switching between |
||
const IS_SOURCE_PREACT_X_OR_ABOVE = isInstalledVersionPreactXOrAbove(cwd); | ||
// Apply base-level `env` values | ||
env.dest = resolve(cwd, env.dest || 'build'); | ||
|
@@ -219,20 +219,15 @@ module.exports = function createBaseConfig(env) { | |
], | ||
}, | ||
{ | ||
// User styles | ||
test: /\.(p?css|less|s[ac]ss|styl)$/, | ||
include: [source('components'), source('routes')], | ||
exclude: /\.module\.(p?css|less|s[ac]ss|styl)$/, | ||
use: [ | ||
isWatch | ||
? require.resolve('style-loader') | ||
: MiniCssExtractPlugin.loader, | ||
isProd | ||
? MiniCssExtractPlugin.loader | ||
: require.resolve('style-loader'), | ||
{ | ||
loader: require.resolve('css-loader'), | ||
options: { | ||
modules: { | ||
localIdentName: '[local]__[hash:base64:5]', | ||
}, | ||
importLoaders: 1, | ||
sourceMap: true, | ||
}, | ||
}, | ||
|
@@ -246,18 +241,25 @@ module.exports = function createBaseConfig(env) { | |
}, | ||
}, | ||
], | ||
// Don't consider CSS imports dead code even if the | ||
// containing package claims to have no side effects. | ||
// Remove this when webpack adds a warning or an error for this. | ||
// See https://github.com/webpack/webpack/issues/6571 | ||
sideEffects: true, | ||
}, | ||
{ | ||
// External / `node_module` styles | ||
test: /\.(p?css|less|s[ac]ss|styl)$/, | ||
exclude: [source('components'), source('routes')], | ||
test: /\.module\.(p?css|less|s[ac]ss|styl)$/, | ||
use: [ | ||
isWatch | ||
? require.resolve('style-loader') | ||
: MiniCssExtractPlugin.loader, | ||
isProd | ||
? MiniCssExtractPlugin.loader | ||
: require.resolve('style-loader'), | ||
{ | ||
loader: require.resolve('css-loader'), | ||
options: { | ||
modules: { | ||
localIdentName: '[local]__[hash:base64:5]', | ||
}, | ||
importLoaders: 1, | ||
sourceMap: true, | ||
}, | ||
}, | ||
|
@@ -271,11 +273,6 @@ module.exports = function createBaseConfig(env) { | |
}, | ||
}, | ||
], | ||
// Don't consider CSS imports dead code even if the | ||
// containing package claims to have no side effects. | ||
// Remove this when webpack adds a warning or an error for this. | ||
// See https://github.com/webpack/webpack/issues/6571 | ||
sideEffects: true, | ||
}, | ||
{ | ||
test: /\.(xml|html|txt|md)$/, | ||
|
@@ -366,7 +363,7 @@ module.exports = function createBaseConfig(env) { | |
|
||
mode: isProd ? 'production' : 'development', | ||
|
||
devtool: isWatch ? 'eval-cheap-module-source-map' : 'source-map', | ||
devtool: isProd ? 'source-map' : 'eval-cheap-module-source-map', | ||
|
||
node: { | ||
__filename: false, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed when debugging.
We attempt to log warnings if
stats.hasWarnings()
is true:preact-cli/packages/cli/lib/lib/webpack/run-webpack.js
Lines 167 to 169 in 3f389c2
However,
info.warnings
will always be empty w/out this change.