@atomicsmash/compiler 0.2.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAqBA,OAAO,CAAC,MAAM,CAAC;IAEd,UAAU,MAAM,CAAC;QAEhB,UAAU,UAAU;YACnB,QAAQ,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;SAC5D;KACD;CACD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAsBA,OAAO,CAAC,MAAM,CAAC;IAEd,UAAU,MAAM,CAAC;QAEhB,UAAU,UAAU;YACnB,QAAQ,EAAE,YAAY,GAAG,aAAa,GAAG,MAAM,GAAG,SAAS,CAAC;SAC5D;KACD;CACD"}
package/dist/index.js CHANGED
@@ -4,6 +4,8 @@ import DependencyExtractionWebpackPlugin from "@wordpress/dependency-extraction-
4
4
  import CopyPlugin from "copy-webpack-plugin";
5
5
  import cssNano from "cssnano";
6
6
  import glob from "fast-glob";
7
+ import postCSSIncreaseSpecificity from "postcss-increase-specificity";
8
+ import postCSSContext from "postcss-plugin-context";
7
9
  import postCSSPresetEnv from "postcss-preset-env";
8
10
  import SVGSpritemapPlugin from "svg-spritemap-webpack-plugin";
9
11
  import { TsconfigPathsPlugin } from "tsconfig-paths-webpack-plugin";
@@ -42,16 +44,24 @@ const MODE = process.env.NODE_ENV === "development" || process.env.NODE_ENV ===
42
44
  : "production";
43
45
  const srcFolder = resolvePath(argv.in);
44
46
  const distFolder = resolvePath(argv.out);
45
- // @ts-expect-error -- Module doesn't need to be installed in compiler package.
47
+ // Add optional support for Tailwind if tailwind postcss plugin is installed
46
48
  const tailwindPostCSSPlugin = await import("@tailwindcss/postcss")
47
- .then((tailwindPostCSS) => [
48
- tailwindPostCSS.default,
49
- ])
50
- .catch(async () =>
51
- // @ts-expect-error -- Module doesn't need to be installed in compiler package.
52
- await import("tailwindcss")
49
+ .then((tailwindPostCSS) => [tailwindPostCSS.default])
50
+ .catch(async () => await import("tailwindcss")
53
51
  .then((tailwindcss) => [tailwindcss.default])
54
52
  .catch(() => []));
53
+ // Add optional support for Vue if vue-loader is installed
54
+ const vueConfig = await import("vue-loader")
55
+ .then((vueLoaderModule) => ({
56
+ loader: [
57
+ {
58
+ test: /\.vue$/,
59
+ loader: "vue-loader",
60
+ },
61
+ ],
62
+ plugin: [new vueLoaderModule.VueLoaderPlugin()],
63
+ }))
64
+ .catch(() => ({ loader: [], plugin: [] }));
55
65
  const postCSSConfig = [
56
66
  [
57
67
  ...tailwindPostCSSPlugin,
@@ -61,6 +71,12 @@ const postCSSConfig = [
61
71
  "custom-media-queries": true,
62
72
  },
63
73
  }),
74
+ postCSSContext({
75
+ wordpressEditor: postCSSIncreaseSpecificity({
76
+ repeat: 1,
77
+ stackableRoot: ".is-root-container",
78
+ }),
79
+ }),
64
80
  ],
65
81
  ...(MODE === "production" ? [cssNano] : []),
66
82
  ];
@@ -73,13 +89,10 @@ const compiler = webpack({
73
89
  },
74
90
  devtool: MODE === "development" ? "source-map" : false,
75
91
  mode: MODE,
76
- experiments: {
77
- outputModule: true,
78
- },
79
92
  entry: await glob([
80
- `${srcFolder}/js/*.{js,ts}`,
93
+ `${srcFolder}/js/*.{js,ts,jsx,tsx}`,
81
94
  `${srcFolder}/css/*.css`,
82
- `${srcFolder}/css/*.s[ac]ss`,
95
+ `${srcFolder}/css/**/[^_]*.s[ac]ss`,
83
96
  ]).then((paths) => {
84
97
  const entryPoints = {};
85
98
  paths.forEach((path) => {
@@ -95,10 +108,8 @@ const compiler = webpack({
95
108
  filename: "js/[name].[contenthash].js",
96
109
  clean: true,
97
110
  library: {
98
- type: "modern-module",
111
+ type: "umd",
99
112
  },
100
- libraryTarget: "module",
101
- module: true,
102
113
  path: distFolder,
103
114
  },
104
115
  resolve: {
@@ -107,15 +118,30 @@ const compiler = webpack({
107
118
  },
108
119
  module: {
109
120
  rules: [
121
+ ...vueConfig.loader,
110
122
  {
111
123
  test: /\.[jt]sx?$/,
112
124
  use: {
113
125
  loader: "babel-loader",
114
126
  options: {
115
- presets: ["@babel/preset-typescript", "@babel/preset-env"],
127
+ presets: [
128
+ "@babel/preset-typescript",
129
+ [
130
+ "@babel/preset-react",
131
+ {
132
+ runtime: "automatic",
133
+ },
134
+ ],
135
+ "@babel/preset-env",
136
+ ],
116
137
  },
117
138
  },
118
- exclude: /node_modules/,
139
+ exclude: (file) => {
140
+ if (vueConfig.loader.length > 0) {
141
+ return file.includes("node_modules") && !file.includes(".vue.js");
142
+ }
143
+ return file.includes("node_modules");
144
+ },
119
145
  },
120
146
  {
121
147
  test: /\.s[ac]ss$/i,
@@ -214,6 +240,7 @@ const compiler = webpack({
214
240
  new DependencyExtractionWebpackPlugin({
215
241
  combineAssets: true,
216
242
  }),
243
+ ...vueConfig.plugin,
217
244
  ],
218
245
  });
219
246
  if (argv.watch) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicsmash/compiler",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.4.0",
5
5
  "description": "A universal compiler for all Atomic Smash projects.",
6
6
  "keywords": [
7
7
  "cli",
@@ -53,7 +53,9 @@
53
53
  "cssnano": "^7.0.6",
54
54
  "fast-glob": "^3.3.2",
55
55
  "postcss": "^8.4.49",
56
+ "postcss-increase-specificity": "^0.6.0",
56
57
  "postcss-loader": "^8.1.1",
58
+ "postcss-plugin-context": "^2.0.0",
57
59
  "postcss-preset-env": "^10.1.3",
58
60
  "sass": "^1.83.1",
59
61
  "sass-loader": "^16.0.4",
@@ -66,10 +68,13 @@
66
68
  "yargs": "^17.7.2"
67
69
  },
68
70
  "devDependencies": {
71
+ "@tailwindcss/postcss": "^4.0.9",
69
72
  "@types/svg-spritemap-webpack-plugin": "^4.4.4",
70
73
  "@types/webpack": "^5.28.5",
71
74
  "@types/webpack-assets-manifest": "^5.1.4",
72
75
  "@types/webpack-bundle-analyzer": "^4.7.0",
73
- "@types/yargs": "^17.0.33"
76
+ "@types/yargs": "^17.0.33",
77
+ "tailwindcss": "^4.0.9",
78
+ "vue-loader": "^17.4.2"
74
79
  }
75
80
  }