Skip to content

e2e : webpack example for global data #880

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

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
1 change: 1 addition & 0 deletions e2e/interop/global-data--webpack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
1 change: 1 addition & 0 deletions e2e/interop/global-data--webpack/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.8.0
1 change: 1 addition & 0 deletions e2e/interop/global-data--webpack/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './styles.css';
23 changes: 23 additions & 0 deletions e2e/interop/global-data--webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@csstools/interop--global-data--webpack",
"version": "0.0.0",
"private": true,
"description": "Can you use webpack + postcss-loader with postcss-global-data?",
"main": "index.js",
"scripts": {
"build": "webpack --config webpack.config.js"
},
"dependencies": {
"@csstools/postcss-global-data": "file:../../../plugins/postcss-global-data",
"css-loader": "^6.7.1",
"postcss": "^8.4.20",
"postcss-loader": "^7.0.0",
"postcss-preset-env": "file:../../../plugin-packs/postcss-preset-env",
"style-loader": "^3.3.1",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1"
},
"volta": {
"extends": "../../package.json"
}
}
3 changes: 3 additions & 0 deletions e2e/interop/global-data--webpack/props.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:root {
--color: pink;
}
3 changes: 3 additions & 0 deletions e2e/interop/global-data--webpack/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.a {
color: var(--color);
}
50 changes: 50 additions & 0 deletions e2e/interop/global-data--webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const path = require('path');
const postcssGlobalData = require('@csstools/postcss-global-data');

module.exports = {
mode: 'production',
entry: './index.js',
target: 'node',
optimization: {
minimize: false,
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.cjs',
},
module: {
rules: [
// We document how to use our plugins together with Webpack.
// This test validates this documentation.
{
test: /\.css$/i,
use: [
'style-loader',
{
loader: 'css-loader',
options: { importLoaders: 1 },
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
postcssGlobalData({
files: ['./props.css'],
}),
[
'postcss-preset-env',
{
stage: 0,
preserve: false,
},
],
],
},
},
},
],
},
],
},
};
18 changes: 17 additions & 1 deletion e2e/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.