Commit 755dc409 authored by Guy Bedford's avatar Guy Bedford Committed by Joe Haddad

postcss loaders

parent a3ec26d3
...@@ -29,7 +29,7 @@ export function getGlobalCssLoader( ...@@ -29,7 +29,7 @@ export function getGlobalCssLoader(
// Compile CSS // Compile CSS
loaders.push({ loaders.push({
loader: require.resolve('postcss-loader'), loader: require.resolve('next/dist/compiled/postcss-loader'),
options: { options: {
ident: '__nextjs_postcss', ident: '__nextjs_postcss',
plugins: postCssPlugins, plugins: postCssPlugins,
......
...@@ -45,7 +45,7 @@ export function getCssModuleLoader( ...@@ -45,7 +45,7 @@ export function getCssModuleLoader(
// Compile CSS // Compile CSS
loaders.push({ loaders.push({
loader: require.resolve('postcss-loader'), loader: require.resolve('next/dist/compiled/postcss-loader'),
options: { options: {
ident: '__nextjs_postcss', ident: '__nextjs_postcss',
plugins: postCssPlugins, plugins: postCssPlugins,
......
...@@ -84,9 +84,9 @@ function getDefaultPlugins( ...@@ -84,9 +84,9 @@ function getDefaultPlugins(
} catch {} } catch {}
return [ return [
require.resolve('postcss-flexbugs-fixes'), require.resolve('next/dist/compiled/postcss-flexbugs-fixes'),
[ [
require.resolve('postcss-preset-env'), require.resolve('next/dist/compiled/postcss-preset-env'),
{ {
browsers: browsers ?? ['defaults'], browsers: browsers ?? ['defaults'],
autoprefixer: { autoprefixer: {
......
import { process as minify } from 'cssnano-simple' import { process as minify } from 'next/dist/compiled/cssnano-simple'
import webpack from 'webpack' import webpack from 'webpack'
import { RawSource, SourceMapSource } from 'webpack-sources' import { RawSource, SourceMapSource } from 'webpack-sources'
......
...@@ -80,16 +80,13 @@ ...@@ -80,16 +80,13 @@
"babel-plugin-transform-react-remove-prop-types": "0.4.24", "babel-plugin-transform-react-remove-prop-types": "0.4.24",
"browserslist": "4.8.3", "browserslist": "4.8.3",
"css-loader": "3.3.0", "css-loader": "3.3.0",
"cssnano-simple": "1.0.0",
"fork-ts-checker-webpack-plugin": "3.1.1", "fork-ts-checker-webpack-plugin": "3.1.1",
"jest-worker": "24.9.0", "jest-worker": "24.9.0",
"loader-utils": "2.0.0", "loader-utils": "2.0.0",
"mini-css-extract-plugin": "0.8.0", "mini-css-extract-plugin": "0.8.0",
"native-url": "0.2.6", "native-url": "0.2.6",
"pnp-webpack-plugin": "1.5.0", "pnp-webpack-plugin": "1.5.0",
"postcss-flexbugs-fixes": "4.2.0", "postcss": "7.0.27",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"prop-types-exact": "1.2.0", "prop-types-exact": "1.2.0",
"react-is": "16.8.6", "react-is": "16.8.6",
...@@ -160,6 +157,7 @@ ...@@ -160,6 +157,7 @@
"conf": "5.0.0", "conf": "5.0.0",
"content-type": "1.0.4", "content-type": "1.0.4",
"cookie": "0.4.0", "cookie": "0.4.0",
"cssnano-simple": "1.0.0",
"devalue": "2.0.1", "devalue": "2.0.1",
"dotenv": "8.2.0", "dotenv": "8.2.0",
"dotenv-expand": "5.1.0", "dotenv-expand": "5.1.0",
...@@ -183,6 +181,9 @@ ...@@ -183,6 +181,9 @@
"node-fetch": "2.6.0", "node-fetch": "2.6.0",
"ora": "3.4.0", "ora": "3.4.0",
"path-to-regexp": "6.1.0", "path-to-regexp": "6.1.0",
"postcss-flexbugs-fixes": "4.2.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"raw-body": "2.4.0", "raw-body": "2.4.0",
"react-error-overlay": "5.1.6", "react-error-overlay": "5.1.6",
"recast": "0.18.5", "recast": "0.18.5",
......
...@@ -172,6 +172,14 @@ export async function ncc_cookie(task, opts) { ...@@ -172,6 +172,14 @@ export async function ncc_cookie(task, opts) {
.target('dist/compiled/cookie') .target('dist/compiled/cookie')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['cssnano-simple'] = 'next/dist/compiled/cssnano-simple'
export async function ncc_cssnano_simple(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('cssnano-simple')))
.ncc({ packageName: 'cssnano-simple', externals })
.target('dist/compiled/cssnano-simple')
}
// eslint-disable-next-line camelcase
externals['devalue'] = 'next/dist/compiled/devalue' externals['devalue'] = 'next/dist/compiled/devalue'
export async function ncc_devalue(task, opts) { export async function ncc_devalue(task, opts) {
await task await task
...@@ -342,6 +350,35 @@ export async function ncc_ora(task, opts) { ...@@ -342,6 +350,35 @@ export async function ncc_ora(task, opts) {
.target('dist/compiled/ora') .target('dist/compiled/ora')
} }
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
externals['postcss-flexbugs-fixes'] =
'next/dist/compiled/postcss-flexbugs-fixes'
export async function ncc_postcss_flexbugs_fixes(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-flexbugs-fixes'))
)
.ncc({ packageName: 'postcss-flexbugs-fixes', externals })
.target('dist/compiled/postcss-flexbugs-fixes')
}
// eslint-disable-next-line camelcase
externals['postcss-loader'] = 'next/dist/compiled/postcss-loader'
export async function ncc_postcss_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('postcss-loader')))
.ncc({ packageName: 'postcss-loader', externals })
.target('dist/compiled/postcss-loader')
}
// eslint-disable-next-line camelcase
externals['postcss-preset-env'] = 'next/dist/compiled/postcss-preset-env'
export async function ncc_postcss_preset_env(task, opts) {
await task
.source(
opts.src || relative(__dirname, require.resolve('postcss-preset-env'))
)
.ncc({ packageName: 'postcss-preset-env', externals })
.target('dist/compiled/postcss-preset-env')
}
// eslint-disable-next-line camelcase
externals['raw-body'] = 'next/dist/compiled/raw-body' externals['raw-body'] = 'next/dist/compiled/raw-body'
export async function ncc_raw_body(task, opts) { export async function ncc_raw_body(task, opts) {
await task await task
...@@ -486,6 +523,7 @@ export async function precompile(task) { ...@@ -486,6 +523,7 @@ export async function precompile(task) {
'ncc_conf', 'ncc_conf',
'ncc_content_type', 'ncc_content_type',
'ncc_cookie', 'ncc_cookie',
'ncc_cssnano_simple',
'ncc_devalue', 'ncc_devalue',
'ncc_dotenv', 'ncc_dotenv',
'ncc_dotenv_expand', 'ncc_dotenv_expand',
...@@ -507,6 +545,9 @@ export async function precompile(task) { ...@@ -507,6 +545,9 @@ export async function precompile(task) {
'ncc_nanoid', 'ncc_nanoid',
'ncc_node_fetch', 'ncc_node_fetch',
'ncc_ora', 'ncc_ora',
'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env',
'ncc_raw_body', 'ncc_raw_body',
'ncc_recast', 'ncc_recast',
'ncc_resolve', 'ncc_resolve',
......
...@@ -71,6 +71,10 @@ declare module 'next/dist/compiled/cookie' { ...@@ -71,6 +71,10 @@ declare module 'next/dist/compiled/cookie' {
import m from 'cookie' import m from 'cookie'
export = m export = m
} }
declare module 'next/dist/compiled/cssnano-simple' {
import m from 'cssnano-simple'
export = m
}
declare module 'next/dist/compiled/devalue' { declare module 'next/dist/compiled/devalue' {
import m from 'devalue' import m from 'devalue'
export = m export = m
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment