Skip to content

Fixing a bug where @import CSS files were not put through the autoprexer #108

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

Merged
merged 1 commit into from
Jul 25, 2017
Merged
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
1 change: 1 addition & 0 deletions fixtures/css/imports_autoprefixer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "autoprefixer_test.css";
11 changes: 9 additions & 2 deletions lib/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,24 @@ const loaderFeatures = require('../loader-features');
*/
module.exports = {
getLoaders(webpackConfig, skipPostCssLoader) {
const usePostCssLoader = webpackConfig.usePostCssLoader && !skipPostCssLoader;

const cssLoaders = [
{
loader: 'css-loader',
options: {
minimize: webpackConfig.isProduction(),
sourceMap: webpackConfig.useSourceMaps
sourceMap: webpackConfig.useSourceMaps,
// when using @import, how many loaders *before* css-loader should
// be applied to those imports? This defaults to 0. When postcss-loader
// is used, we set it to 1, so that postcss-loader is applied
// to @import resources.
importLoaders: usePostCssLoader ? 1 : 0
}
},
];

if (webpackConfig.usePostCssLoader && !skipPostCssLoader) {
if (usePostCssLoader) {
loaderFeatures.ensureLoaderPackagesExist('postcss');

cssLoaders.push({
Expand Down
4 changes: 3 additions & 1 deletion test/functional.js
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,9 @@ module.exports = {

const config = testSetup.createWebpackConfig(appDir, 'www/build', 'dev');
config.setPublicPath('/build');
config.addStyleEntry('styles', ['./css/autoprefixer_test.css']);
// load a file that @import's another file, so that we can
// test that @import resources are parsed through postcss
config.addStyleEntry('styles', ['./css/imports_autoprefixer.css']);
config.enablePostCssLoader();

testSetup.runWebpack(config, (webpackAssert) => {
Expand Down