Skip to content
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

Allow using css-modules with SASS, LESS and Stylus #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 52 additions & 2 deletions packages/react-scripts/config/customizers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var cssModulesDev = '?modules&camelCase&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]';
var cssModulesProd = '?modules&camelCase&-autoprefixer&importLoaders=1';

module.exports = {
'BABEL_STAGE_0': {
Expand Down Expand Up @@ -29,6 +31,22 @@ module.exports = {
}
}
},
'SASS_MODULES': {
toArray: 'loaders',
fileRegex: /\.(scss|sass)/,
getDev: function () {
return {
test: /(\.scss|\.sass)$/,
loader: `style!css${cssModulesDev}!postcss!sass`
}
},
getProd: function () {
return {
test: /(\.scss|\.sass)$/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!sass`)
}
}
},
'LESS': {
toArray: 'loaders',
fileRegex: /\.less$/,
Expand All @@ -45,6 +63,22 @@ module.exports = {
}
}
},
'LESS_MODULES': {
toArray: 'loaders',
fileRegex: /\.less$/,
getDev: function () {
return {
test: /\.less$/,
loader: `style!css${cssModulesDev}!postcss!less`
}
},
getProd: function () {
return {
test: /\.less/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!less`)
}
}
},
'STYLUS': {
toArray: 'loaders',
fileRegex: /\.styl$/,
Expand All @@ -61,10 +95,26 @@ module.exports = {
}
}
},
'STYLUS_MODULES': {
toArray: 'loaders',
fileRegex: /\.styl$/,
getDev: function () {
return {
test: /\.styl/,
loader: `style!css${cssModulesDev}!postcss!stylus`
}
},
getProd: function () {
return {
test: /\.styl/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!stylus`)
}
}
},
'CSS_MODULES': {
config: {
dev: 'style!css?modules&camelCase&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss',
prod: 'style!css?modules&camelCase&-autoprefixer&importLoaders=1!postcss'
dev: `style!css${cssModulesDev}!postcss`,
prod: `style!css${cssModulesProd}!postcss`
}
}
}
125 changes: 125 additions & 0 deletions packages/react-scripts/config/customizers.js.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var cssModulesDev = '?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]';
var cssModulesProd = '?modules&-autoprefixer&importLoaders=1';

module.exports = {
'BABEL_STAGE_0': {
toArray: 'presets',
getDev: function () {
return require.resolve('babel-preset-stage-0')
}
},
'DECORATORS': {
toArray: 'babelPlugins',
getDev: function () {
return require.resolve('babel-plugin-transform-decorators-legacy')
}
},
'SASS': {
toArray: 'loaders',
fileRegex: /\.(scss|sass)/,
getDev: function () {
return {
test: /(\.scss|\.sass)$/,
loader: "style!css!postcss!sass"
}
},
getProd: function () {
return {
test: /(\.scss|\.sass)$/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!sass')
}
}
},
'SASS_MODULES': {
toArray: 'loaders',
fileRegex: /\.(scss|sass)/,
getDev: function () {
return {
test: /(\.scss|\.sass)$/,
loader: `style!css${cssModulesDev}!postcss!sass`
}
},
getProd: function () {
return {
test: /(\.scss|\.sass)$/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!sass`)
}
}
},
'LESS': {
toArray: 'loaders',
fileRegex: /\.less$/,
getDev: function () {
return {
test: /\.less$/,
loader: "style!css!postcss!less"
}
},
getProd: function () {
return {
test: /\.less/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!less')
}
}
},
'LESS_MODULES': {
toArray: 'loaders',
fileRegex: /\.less$/,
getDev: function () {
return {
test: /\.less$/,
loader: `style!css${cssModulesDev}!postcss!less`
}
},
getProd: function () {
return {
test: /\.less/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!less`)
}
}
},
'STYLUS': {
toArray: 'loaders',
fileRegex: /\.styl$/,
getDev: function () {
return {
test: /\.styl/,
loader: 'style!css!postcss!stylus'
}
},
getProd: function () {
return {
test: /\.styl/,
loader: ExtractTextPlugin.extract('style', 'css!postcss!stylus')
}
}
},
'STYLUS_MODULES': {
toArray: 'loaders',
fileRegex: /\.styl$/,
getDev: function () {
return {
test: /\.styl/,
loader: `style!css${cssModulesDev}!postcss!stylus`
}
},
getProd: function () {
return {
test: /\.styl/,
loader: ExtractTextPlugin.extract('style', `css${cssModulesProd}!postcss!stylus`)
}
}
},
'CSS_MODULES': {
config: {
<<<<<<< HEAD
dev: 'style!css?modules&camelCase&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss',
prod: 'style!css?modules&camelCase&-autoprefixer&importLoaders=1!postcss'
=======
dev: `style!css${cssModulesDev}!postcss`,
prod: `style!css${cssModulesProd}!postcss`
>>>>>>> Allow using css-modules with SASS, LESS and Stylus
}
}
}
Loading