Skip to content
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
13 changes: 11 additions & 2 deletions packages/cli/lib/lib/webpack/webpack-base-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const ReplacePlugin = require('webpack-plugin-replace');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const createBabelConfig = require('../babel-config');
const loadPostcssConfig = require('postcss-load-config');

function readJson(file) {
try {
Expand Down Expand Up @@ -84,6 +85,14 @@ module.exports = function(env) {

let tsconfig = resolveTsconfig(cwd, isProd);

let postcssPlugins;

try {
postcssPlugins = loadPostcssConfig.sync(cwd).plugins;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, just wondering if we should load more than just the plugins?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

Okay, forgive the long response, but here are my thoughts on loading more than just the plugins from a PostCSS configuration.

The other options are to, map, from, parser, syntax, and stringifier.

I am confident that to and from can be ignored because webpack determines those locations. I am somewhat confident that parser, syntax, and stringifier can be ignored at this time, because css-loader and style-loader can still choke on non-CSS syntaxes.

I am on the fence about map. On the one hand, it can be ignored, because source map configuration needs to be unified across all CSS loaders in order to be useful. However, if PostCSS configuration enables or disables CSS source maps for a project, then that does sound useful. The question is whether PostCSS configuration is the most logical place to put control over CSS source maps.

} catch (error) {
postcssPlugins = [autoprefixer({ overrideBrowserslist: browsers })];
}

return {
context: src,

Expand Down Expand Up @@ -208,7 +217,7 @@ module.exports = function(env) {
options: {
ident: 'postcss',
sourceMap: true,
plugins: [autoprefixer({ overrideBrowserslist: browsers })],
plugins: postcssPlugins,
},
},
],
Expand All @@ -230,7 +239,7 @@ module.exports = function(env) {
options: {
ident: 'postcss',
sourceMap: true,
plugins: [autoprefixer({ overrideBrowserslist: browsers })],
plugins: postcssPlugins,
},
},
],
Expand Down
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"minimatch": "^3.0.3",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"ora": "^3.4.0",
"postcss-load-config": "^2.1.0",
"postcss-loader": "^3.0.0",
"progress-bar-webpack-plugin": "^1.12.1",
"promise-polyfill": "^8.1.0",
Expand Down