This repository has been archived by the owner on Oct 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Replace extract-text-webpack-plugin with mini-css-extract #265
Open
ruisalgado
wants to merge
3
commits into
master
Choose a base branch
from
use-mini-css-extract
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−74
Open
Changes from all commits
Commits
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
const path = require("path"); | ||
const webpack = require("webpack"); | ||
const babel = require("./config/babel"); | ||
const uglify = require("./config/uglify"); | ||
|
||
const env = process.env.NODE_ENV || "development"; | ||
const useCordova = (process.env.USE_CORDOVA || "false") === "true"; | ||
|
@@ -10,27 +9,26 @@ const hotReload = process.env.LIVERELOAD === "true" && !isProd; | |
const out = path.resolve(__dirname, "dist"); | ||
const exclusions = /node_modules/; | ||
|
||
const ExtractText = require("extract-text-webpack-plugin"); | ||
const extractShellCss = new ExtractText("shell.[hash].css"); | ||
const extractOtherCss = new ExtractText("styles.[hash].css"); | ||
|
||
process.stderr.write(`Building with env = ${env}\n`); | ||
|
||
// plugin management | ||
const HTML = require("html-webpack-plugin"); | ||
const Clean = require("clean-webpack-plugin"); | ||
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); | ||
const SpriteLoaderPlugin = require("svg-sprite-loader/plugin"); | ||
const plugins = [ | ||
...require("maji/lib/webpack").plugins, | ||
new HTML({ | ||
template: "src/index.html", | ||
useCordova, | ||
inject: false, | ||
minify: false | ||
inject: true, | ||
minify: isProd | ||
}), | ||
new Clean(["dist"], { verbose: false, exclude: [".keep"] }), | ||
extractShellCss, | ||
extractOtherCss, | ||
new MiniCssExtractPlugin({ | ||
filename: "[name].[contenthash].css", | ||
chunkFilename: "[id].[contenthash].css" | ||
}), | ||
new SpriteLoaderPlugin() | ||
]; | ||
|
||
|
@@ -115,31 +113,28 @@ module.exports = { | |
{ test: /\.yml$/, loader: "json-loader!yaml-loader" }, | ||
{ | ||
test: /\.scss$/, | ||
loader: isProd | ||
? extractOtherCss.extract({ | ||
use: ["css-loader?modules", postcssLoader, "sass-loader"] | ||
}) | ||
: [ | ||
"style-loader", | ||
{ | ||
loader: "css-loader", | ||
options: { | ||
modules: true, | ||
localIdentName: "[path][name]__[local]--[hash:base64:5]" | ||
} | ||
}, | ||
postcssLoader, | ||
"sass-loader" | ||
], | ||
use: [ | ||
isProd ? MiniCssExtractPlugin.loader : "style-loader", | ||
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. I noticed the produced CSS is not minified. According to the docs this requires a separate plugin. |
||
{ | ||
loader: "css-loader", | ||
options: { | ||
modules: true, | ||
localIdentName: "[path][name]__[local]--[hash:base64:5]" | ||
} | ||
}, | ||
postcssLoader, | ||
"sass-loader" | ||
], | ||
exclude: /shell.scss$/ | ||
}, | ||
{ | ||
test: /shell.scss$/, | ||
loader: isProd | ||
? extractShellCss.extract({ | ||
use: ["css-loader", postcssLoader, "sass-loader"] | ||
}) | ||
: ["style-loader", "css-loader", postcssLoader, "sass-loader"] | ||
use: [ | ||
isProd ? MiniCssExtractPlugin.loader : "style-loader", | ||
"css-loader", | ||
postcssLoader, | ||
"sass-loader" | ||
] | ||
}, | ||
{ | ||
test: /\.svg$/, | ||
|
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 |
---|---|---|
|
@@ -1307,7 +1307,7 @@ async@^1.4.2, async@^1.5.2: | |
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" | ||
integrity sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo= | ||
|
||
async@^2.0.0, async@^2.4.1, async@^2.5.0, async@^2.6.1: | ||
async@^2.0.0, async@^2.5.0, async@^2.6.1: | ||
version "2.6.2" | ||
resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" | ||
integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== | ||
|
@@ -4008,16 +4008,6 @@ extglob@^2.0.2, extglob@^2.0.4: | |
snapdragon "^0.8.1" | ||
to-regex "^3.0.1" | ||
|
||
[email protected]: | ||
version "4.0.0-beta.0" | ||
resolved "https://registry.yarnpkg.com/extract-text-webpack-plugin/-/extract-text-webpack-plugin-4.0.0-beta.0.tgz#f7361d7ff430b42961f8d1321ba8c1757b5d4c42" | ||
integrity sha512-Hypkn9jUTnFr0DpekNam53X47tXn3ucY08BQumv7kdGgeVUBLq3DJHJTi6HNxv4jl9W+Skxjz9+RnK0sJyqqjA== | ||
dependencies: | ||
async "^2.4.1" | ||
loader-utils "^1.1.0" | ||
schema-utils "^0.4.5" | ||
webpack-sources "^1.1.0" | ||
|
||
extract-zip@^1.6.7: | ||
version "1.6.7" | ||
resolved "https://registry.yarnpkg.com/extract-zip/-/extract-zip-1.6.7.tgz#a840b4b8af6403264c8db57f4f1a74333ef81fe9" | ||
|
@@ -6859,6 +6849,16 @@ mimic-fn@^1.0.0: | |
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" | ||
integrity sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ== | ||
|
||
mini-css-extract-plugin@^0.6.0: | ||
version "0.6.0" | ||
resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.6.0.tgz#a3f13372d6fcde912f3ee4cd039665704801e3b9" | ||
integrity sha512-79q5P7YGI6rdnVyIAV4NXpBQJFWdkzJxCim3Kog4078fM0piAaFlwocqbejdWtLW1cEzCexPrh6EdyFsPgVdAw== | ||
dependencies: | ||
loader-utils "^1.1.0" | ||
normalize-url "^2.0.1" | ||
schema-utils "^1.0.0" | ||
webpack-sources "^1.1.0" | ||
|
||
minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" | ||
|
@@ -7355,6 +7355,15 @@ normalize-url@^1.4.0: | |
query-string "^4.1.0" | ||
sort-keys "^1.0.0" | ||
|
||
normalize-url@^2.0.1: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-2.0.1.tgz#835a9da1551fa26f70e92329069a23aa6574d7e6" | ||
integrity sha512-D6MUW4K/VzoJ4rJ01JFKxDrtY1v9wrgzCX5f2qj/lzH1m/lW6MhUZFKerVsnyjOhOsYzI9Kqqak+10l4LvLpMw== | ||
dependencies: | ||
prepend-http "^2.0.0" | ||
query-string "^5.0.1" | ||
sort-keys "^2.0.0" | ||
|
||
npm-bundled@^1.0.1: | ||
version "1.0.6" | ||
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.6.tgz#e7ba9aadcef962bb61248f91721cd932b3fe6bdd" | ||
|
@@ -8590,6 +8599,11 @@ prepend-http@^1.0.0, prepend-http@^1.0.1: | |
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" | ||
integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= | ||
|
||
prepend-http@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" | ||
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= | ||
|
||
preserve@^0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" | ||
|
@@ -8798,6 +8812,15 @@ query-string@^4.1.0, query-string@^4.3.2: | |
object-assign "^4.1.0" | ||
strict-uri-encode "^1.0.0" | ||
|
||
query-string@^5.0.1: | ||
version "5.1.1" | ||
resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.1.tgz#a78c012b71c17e05f2e3fa2319dd330682efb3cb" | ||
integrity sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw== | ||
dependencies: | ||
decode-uri-component "^0.2.0" | ||
object-assign "^4.1.0" | ||
strict-uri-encode "^1.0.0" | ||
|
||
querystring-es3@^0.2.0, querystring-es3@~0.2.0: | ||
version "0.2.1" | ||
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" | ||
|
@@ -9995,6 +10018,13 @@ sort-keys@^1.0.0: | |
dependencies: | ||
is-plain-obj "^1.0.0" | ||
|
||
sort-keys@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-2.0.0.tgz#658535584861ec97d730d6cf41822e1f56684128" | ||
integrity sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg= | ||
dependencies: | ||
is-plain-obj "^1.0.0" | ||
|
||
source-list-map@^2.0.0: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" | ||
|
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.
With this approach the shell CSS is no longer in the head.
For Cordova apps this doesn't really matter a ton, but for PWAs it's nice to have this.
Not sure if it's worth sticking with this though, as the primary use case for Maji remains Cordova apps. WDYT?