Created
March 13, 2017 21:55
-
-
Save auser/b7f6bf6ba3deab659b0012b499c6ecd5 to your computer and use it in GitHub Desktop.
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
const findLoader = (config, test) => { | |
const loaders = [].concat(config.module.loaders); | |
while (loaders.length) { | |
const loader = loaders.shift() | |
if (loader.test && loader.test.toString() === test.toString()) { | |
return { loader, index: loaders.length } | |
} | |
} | |
} | |
module.exports = function override(config, env) { | |
const { loader, index } = findLoader(config, /\.css$/) | |
loader.loader = [ | |
'style', | |
'css?modules=1&importLoaders=1', | |
'postcss' | |
].join('!') | |
loader.exclude = /src\/styles\/index\.css/ | |
config.module.loaders[index] = loader | |
return config; | |
} |
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
{ | |
"name": "movieApp", | |
"version": "0.1.0", | |
"private": true, | |
"devDependencies": { | |
"autoprefixer": "^6.7.7", | |
"babel-plugin-transform-postcss": "^0.1.2", | |
"npm-run-all": "^4.0.2", | |
"postcss": "^5.2.16", | |
"postcss-cli": "^3.0.0-beta", | |
"postcss-import": "^9.1.0", | |
"postcss-modules": "^0.6.4", | |
"precss": "^1.4.0", | |
"react-app-rewired": "^0.6.5", | |
"react-scripts": "0.9.5" | |
}, | |
"dependencies": { | |
"babel": "^6.23.0", | |
"react": "^15.4.2", | |
"react-dom": "^15.4.2" | |
}, | |
"scripts": { | |
"start:react": "react-app-rewired start", | |
"build:react": "react-app-rewired build", | |
"build:styles": "./node_modules/.bin/postcss --config postcss.config.js src/styles/index.css -o src/index.css", | |
"start:styles": "npm run build:styles -- --watch", | |
"start": "npm-run-all --parallel start:*", | |
"build": "npm-run-all build:*", | |
"test": "react-scripts test --env=jsdom", | |
"eject": "react-scripts eject" | |
} | |
} |
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 = ctx => { | |
return { | |
plugins: [ | |
require("postcss-import")(), | |
require("precss")(), | |
require("autoprefixer")({ | |
"browsers": "> 5%", | |
}) | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment