Comments (7)
Tried postcss-rcs
, it works!
Looking forward to webpack plugin
from node-rcs-core.
Btw, babili-webpack-plugin is a good example how to save sourcemaps while transforming code
https://github.com/webpack-contrib/babili-webpack-plugin/blob/master/src/index.js
from node-rcs-core.
Yes thats a pretty big topic, also for me. There will be a webpeck plugin indeed in the future.
I guess postcss won't really work quite well, because I think that a plugin of one thing (js renaming) shouldn't depend on another (css renaming), so is it with postcss and webpack (because I never saw it in production). But the workflow with extract-text-webpack-plugin
seems quite nice.
A short question (as you seem more experienced in webpack than me). If the webpack plugin exists, how would you possibly implement the plugin into the config? Because the css rewrites should happen before rewriting all the js/html stuff.
EDIT Also, where do you apply the postcss plugins?
from node-rcs-core.
where do you apply the postcss plugins?
Both, on webpack loader stage, what means individually for each css module which is imported by js module. And then on webpack plugin stage after extract-text-webpack-plugin
when final css chunk is assembled.
Short example could be
modules: {
rules: [
{
test: /\.css/,
exclude: [/node_modules/],
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: [
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
camelCase: 'dashesOnly',
localIdentName: '[sha512:hash:base64]',
},
},
{
loader: 'postcss-loader',
options: {
plugins: {
'postcss-import': {},
'postcss-nested': {},
'postcss-css-variables': {},
'postcss-color-function': {},
'postcss-calc': {precision: 6},
'autoprefixer': {cascade: false, flexbox: 'no-2009', grid: false},
},
},
},
],
}),
}
],
},
plugins: [
// Extract all individual css-modules into one separate css bundle
new ExtractTextPlugin({
filename: getPath => `../styles/${getPath(`[name].css`)}`,
ignoreOrder: true,
allChunks: true,
}),
// Apply css optimizations on that separate css bundle result
new PostcssAssetsPlugin({
test: /\.css$/,
log: true,
plugins: {
'css-mqpacker': {},
'csswring': {preservehacks: true, removeallcomments: true},
},
}),
],
PostcssAssetsPlugin runs on result big css file, and compress its in a whole instead of each separate css modules (it's more effective).
On that plugin stage css and js files are already built, so you can modify them, for instance, using postcss plugin to gather and replace all class names and using separate webpack plugin replace them in built js.
It could be like
plugins: [
// Extract all individual css-modules into one separate css bundle
new ExtractTextPlugin({
filename: getPath => `../styles/${getPath(`[name].css`)}`,
ignoreOrder: true,
allChunks: true,
}),
// Apply css optimizations on that separate css bundle result
new PostcssAssetsPlugin({
test: /\.css$/,
log: true,
plugins: {
'rcs': {__some_options__},
'css-mqpacker': {},
'csswring': {preservehacks: true, removeallcomments: true},
},
}),
new RCSPlugin({test: /\.js$/}, {__some_options__}})
],
from node-rcs-core.
Wow that seems easier than I though it could be. Thanks for this hint. I will try to start soon to make those two plugins.
from node-rcs-core.
@klimashkin the postcss plugin is ready: postcss-rcs. I'm heading now to the webpack plugin.
from node-rcs-core.
@klimashkin I had some time and created the webpack plugin
https://github.com/JPeer264/rcs-webpack-plugin
from node-rcs-core.
Related Issues (20)
- False positive
- More consistent stats
- Remove `options.extend`
- Apply fix from v2.6.3 into master
- Remove `merge` wherever possible
- `_conflict` should get handled differently HOT 4
- [Feature request] Optimize replacement HOT 1
- Add dev mode
- Sourcemaps
- Add new test case
- Is there a safe way to allow certain CSS class names on a case-by-case basis? HOT 4
- Branch: master -> main
- How to include class names containing colon HOT 4
- Class names with square brackets and escaped characters HOT 2
- Problem with noscript tag HOT 5
- Twig templates support HOT 1
- A problem with renaming CSS variables HOT 1
- Multiple class selectors on same element in a PHP file HOT 5
- Regarding Updating Major Espree Version - HOT 4
- Does not prefix classes named after html elements? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-rcs-core.