Skip to content

Commit

Permalink
Merge pull request #4 from jdf2e/master
Browse files Browse the repository at this point in the history
merge origin
  • Loading branch information
beanlee authored Aug 20, 2020
2 parents ad11577 + 6e06a61 commit c57a613
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"optimize-css-assets-webpack-plugin": "^5.0.1",
"postcss-flexbugs-fixes": "^4.1.0",
"postcss-loader": "^3.0.0",
"prettier": "^1.14.3",
"prettier": "^2.0.0",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-router-dom": "^4.3.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketact-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rocketact-scripts",
"version": "1.9.3",
"version": "1.9.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
84 changes: 70 additions & 14 deletions packages/rocketact-scripts/src/config/webpack/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { isDevelopmentEnv, isProductionEnv } from "../../utils/environment";
import { getValidEntries, appRoot, appSrc } from "rocketact-dev-utils";

export default (api: CoreAPI) => {
api.chainWebpack(webpackChain => {
api.chainWebpack((webpackChain) => {
webpackChain.module
.rule("font")
.test(/\.(ttf|eot|woff|woff2)$/)
.use("file")
.loader(require.resolve("file-loader"))
.options({
name: "css/fonts/[name].[ext]"
name: "css/fonts/[name].[ext]",
})
.end()
.end()
Expand All @@ -27,7 +27,7 @@ export default (api: CoreAPI) => {
.use("babel")
.loader(require.resolve("babel-loader"))
.options({
presets: [require.resolve("babel-preset-rocketact")]
presets: [require.resolve("babel-preset-rocketact")],
})
.end()
.end()
Expand All @@ -36,64 +36,120 @@ export default (api: CoreAPI) => {
if (isDevelopmentEnv()) {
webpackChain.module
.rule("scss")
.test(/\.(css|sass|scss)$/)
.test(/(?<!module)\.(css|sass|scss)$/) // extract css-module
.use("style")
.loader(require.resolve("style-loader"))
.options({
sourceMap: true // FIXME: suport setting from --option
sourceMap: true, // FIXME: suport setting from --option
})
.end()
.use("css")
.loader(require.resolve("css-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
modules: true
})
.end()
.use("postcss")
.loader(require.resolve("postcss-loader"))
.options({
sourceMap: true // FIXME: suport setting from --option
sourceMap: true, // FIXME: suport setting from --option
})
.end()
.use("scss")
.loader(require.resolve("sass-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
outputStyle: "compressed",
implementation: require("node-sass")
implementation: require("node-sass"),
})
.end()
.end();

// support css-module
webpackChain.module
.rule("scss-module")
.test(/\.module\.(css|sass|scss)$/)
.use("style")
.loader(require.resolve("style-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
})
.end()
.use("css")
.loader(require.resolve("css-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
modules: true,
// modules: new RegExp(/(module)\.(css|sass|scss)$/).test(webpackChain.module.)
})
.end()
.use("postcss")
.loader(require.resolve("postcss-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
})
.end()
.use("scss")
.loader(require.resolve("sass-loader"))
.options({
sourceMap: true, // FIXME: suport setting from --option
outputStyle: "compressed",
implementation: require("node-sass"),
})
.end()
.end();

webpackChain.module
.rule("image")
.test(/\.(png|jpg|gif|svg|jpeg|webp)$/)
.use("file")
.loader(require.resolve("file-loader"))
.options({
name: "css/i/[name].[hash:8].[ext]",
publicPath: "/"
publicPath: "/",
})
.end();
}

if (isProductionEnv()) {
// support css-module
webpackChain.module
.rule("scss-module")
.test(/\.module\.(css|sass|scss)$/)
.use("mini-css-extract-plugin")
.loader(MiniCssExtractPlugin.loader)
.end()
.use("css")
.loader(require.resolve("css-loader"))
.options({ modules: true })
.end()
.use("postcss")
.loader(require.resolve("postcss-loader"))
.end()
.use("scss")
.loader(require.resolve("sass-loader"))
.options({
implementation: require("node-sass"),
})
.end()
.end();

webpackChain.module
.rule("scss")
.test(/\.(css|sass|scss)$/)
.test(/(?<!module)\.(css|sass|scss)$/) // extract css-module
.use("mini-css-extract-plugin")
.loader(MiniCssExtractPlugin.loader)
.end()
.use("css")
.loader(require.resolve("css-loader"))
.options({modules: true})
.end()
.use("postcss")
.loader(require.resolve("postcss-loader"))
.end()
.use("scss")
.loader(require.resolve("sass-loader"))
.options({
implementation: require("node-sass")
implementation: require("node-sass"),
})
.end()
.end();
Expand All @@ -104,7 +160,7 @@ export default (api: CoreAPI) => {
.use("html")
.loader(require.resolve("html-loader"))
.options({
attrs: ["img:src"]
attrs: ["img:src"],
})
.end()
.end()
Expand All @@ -114,7 +170,7 @@ export default (api: CoreAPI) => {
.loader(require.resolve("url-loader"))
.options({
limit: 10 * 1024,
name: "img/[name].[hash:8].[ext]"
name: "img/[name].[hash:8].[ext]",
})
.end();
}
Expand Down
38 changes: 24 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2754,9 +2754,9 @@ blueimp-md5@^2.3.0:
integrity sha512-EkNUOi7tpV68TqjpiUz9D9NcT8um2+qtgntmMbi5UKssVX2m/2PLqotcric0RE63pB3HPN/fjf3cKHN2ufGSUQ==

bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0:
version "4.11.8"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f"
integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA==
version "4.11.9"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828"
integrity sha512-E6QoYqCKZfgatHTdHzs1RRKP7ip4vvm+EyRUeE2RF0NblwVvb0p6jSVeNTOFxPn26QXN2o6SMfNxKp6kU8zQaw==

[email protected]:
version "1.18.3"
Expand Down Expand Up @@ -3889,7 +3889,7 @@ css-declaration-sorter@^4.0.1:
postcss "^7.0.1"
timsort "^0.3.0"

css-loader@^2.0.1, css-loader@^2.1.0:
css-loader@2.1.0, css-loader@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/css-loader/-/css-loader-2.1.0.tgz#42952ac22bca5d076978638e9813abce49b8f0cc"
integrity sha512-MoOu+CStsGrSt5K2OeZ89q3Snf+IkxRfAIt9aAKg4piioTrhtP1iEFPu+OVn3Ohz24FO6L+rw9UJxBILiSBw5Q==
Expand Down Expand Up @@ -4599,9 +4599,9 @@ elegant-spinner@^1.0.1:
integrity sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=

elliptic@^6.0.0:
version "6.4.1"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.1.tgz#c2d0b7776911b86722c632c3c06c60f2f819939a"
integrity sha512-BsXLz5sqX8OHcsh7CqBMztyXARmGQ3LWPtGjJi6DiJHq5C/qvi9P3OqgswKSDftbu8+IoI/QDTAm2fFnQ9SZSQ==
version "6.5.3"
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6"
integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw==
dependencies:
bn.js "^4.4.0"
brorand "^1.0.1"
Expand Down Expand Up @@ -6292,16 +6292,21 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=
inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, inherits@~2.0.3:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==

[email protected]:
version "2.0.1"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1"
integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=

[email protected]:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=

ini@^1.3.2, ini@^1.3.4, ini@~1.3.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
Expand Down Expand Up @@ -9825,6 +9830,11 @@ prettier@^1.14.3:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"
integrity sha512-ZzWuos7TI5CKUeQAtFd6Zhm2s6EpAD/ZLApIhsF9pRvRtM1RFo61dM/4MSRUA0SuLugA/zgrZD8m0BaY46Og7g==

prettier@^2.0.0:
version "2.0.5"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4"
integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==

pretty-error@^2.0.2:
version "2.1.1"
resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3"
Expand Down Expand Up @@ -12973,9 +12983,9 @@ websocket-driver@>=0.5.1:
websocket-extensions ">=0.1.1"

websocket-extensions@>=0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.3.tgz#5d2ff22977003ec687a4b87073dfbbac146ccf29"
integrity sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==
version "0.1.4"
resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42"
integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg==

whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
version "1.0.5"
Expand Down

0 comments on commit c57a613

Please sign in to comment.