Last active
November 13, 2019 04:58
-
-
Save okumurakengo/e95047926755901499954d95ebc14da0 to your computer and use it in GitHub Desktop.
webpack4でsideEffectsでcssのツリーシェイキングの動きを試してみた
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
/* src/index.css */ | |
body { | |
background: yellow; | |
} |
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
<!DOCTYPE html> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<script src="dist/main.js"></script> |
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
// src/index.js | |
import "./index.css" | |
console.log(123) |
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
{ | |
"devDependencies": { | |
"css-loader": "^3.2.0", | |
"style-loader": "^1.0.0", | |
"webpack": "^4.41.2", | |
"webpack-cli": "^3.3.10" | |
}, | |
"sideEffects": [ | |
"src/index.css" | |
] | |
} |
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
module.exports = { | |
mode: "production", | |
module: { | |
rules: [ | |
{ | |
test: /\.css$/i, | |
use: ["style-loader", "css-loader"], | |
}, | |
], | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment