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

fix https://github.com/vuejs/vue-loader/issues/1395 #30

Closed
wants to merge 2 commits into from
Closed

fix https://github.com/vuejs/vue-loader/issues/1395 #30

wants to merge 2 commits into from

Conversation

JounQin
Copy link
Contributor

@JounQin JounQin commented Sep 5, 2018

@JounQin
Copy link
Contributor Author

JounQin commented Sep 5, 2018

@yyx990803 @sodatea Would you like to review this PR or related issue? It really sucks and it only starts happening recently because css-loader removes minimize feature.

@znck
Copy link
Member

znck commented Oct 23, 2018

Purpose of postcss plugin trim is to remove prepended new lines (used to keep line numbers same as in .vue file). It cannot minimize the css so putting '\n' or '' does not matter. In fact '\n' is correct value here in most cases as newline is there in actual source code, e.g.:

<style>
.foo {
  color: red;
}
</style>

@znck znck closed this Oct 23, 2018
@JounQin
Copy link
Contributor Author

JounQin commented Oct 23, 2018

@znck Did you review the original issue? It makes impossible to minify css totally by postcss anymore.

@znck
Copy link
Member

znck commented Oct 24, 2018

CSS minification should run after @vue/component-compiler-utils is done processing scoped styles and trimming prepended new-lines. To my understanding, it's working correctly and vue-loader has some issue in this regard, vuejs/vue-loader#1395 should be fixed there.

@JounQin
Copy link
Contributor Author

JounQin commented Oct 24, 2018

CSS minification of css-loader has bean removed, so we're using postcss with cssnano to minify CSS, it is really bad to enforce user to minify CSS again after processing postcss.

@znck
Copy link
Member

znck commented Oct 24, 2018

Using a postcss plugin to minimise is good approach.
Does trim creates any problem when used with cssnano?
If so, we can move trim and scoped plugins to the top of list.

if (trim) {
plugins.push(trimPlugin())
}
if (scoped) {
plugins.push(scopedPlugin(id))
}

@JounQin
Copy link
Contributor Author

JounQin commented Oct 24, 2018

The trim plugin is running after cssnano or user customer postcss plugins now, what causes the original issue, and that's why I changed the implement of the trim plugin.

component-compiler-utils itself is running after processing any preprocessors now if we are using vue-loader, what means it has been compiled into css and postprocessed by postcss, postcssPlugins here is always undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

postcss does not work as expected with vue-loader
2 participants