Skip to content

Commit

Permalink
postcss loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored and Timer committed Mar 30, 2020
1 parent a3ec26d commit 755dc40
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getGlobalCssLoader(

// Compile CSS
loaders.push({
loader: require.resolve('postcss-loader'),
loader: require.resolve('next/dist/compiled/postcss-loader'),
options: {
ident: '__nextjs_postcss',
plugins: postCssPlugins,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getCssModuleLoader(

// Compile CSS
loaders.push({
loader: require.resolve('postcss-loader'),
loader: require.resolve('next/dist/compiled/postcss-loader'),
options: {
ident: '__nextjs_postcss',
plugins: postCssPlugins,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/config/blocks/css/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ function getDefaultPlugins(
} catch {}

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'],
autoprefixer: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { process as minify } from 'cssnano-simple'
import { process as minify } from 'next/dist/compiled/cssnano-simple'
import webpack from 'webpack'
import { RawSource, SourceMapSource } from 'webpack-sources'

Expand Down
9 changes: 5 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,13 @@
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"browserslist": "4.8.3",
"css-loader": "3.3.0",
"cssnano-simple": "1.0.0",
"fork-ts-checker-webpack-plugin": "3.1.1",
"jest-worker": "24.9.0",
"loader-utils": "2.0.0",
"mini-css-extract-plugin": "0.8.0",
"native-url": "0.2.6",
"pnp-webpack-plugin": "1.5.0",
"postcss-flexbugs-fixes": "4.2.0",
"postcss-loader": "3.0.0",
"postcss-preset-env": "6.7.0",
"postcss": "7.0.27",
"prop-types": "15.7.2",
"prop-types-exact": "1.2.0",
"react-is": "16.8.6",
Expand Down Expand Up @@ -160,6 +157,7 @@
"conf": "5.0.0",
"content-type": "1.0.4",
"cookie": "0.4.0",
"cssnano-simple": "1.0.0",
"devalue": "2.0.1",
"dotenv": "8.2.0",
"dotenv-expand": "5.1.0",
Expand All @@ -183,6 +181,9 @@
"node-fetch": "2.6.0",
"ora": "3.4.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",
"react-error-overlay": "5.1.6",
"recast": "0.18.5",
Expand Down
41 changes: 41 additions & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ export async function ncc_cookie(task, opts) {
.target('dist/compiled/cookie')
}
// 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'
export async function ncc_devalue(task, opts) {
await task
Expand Down Expand Up @@ -342,6 +350,35 @@ export async function ncc_ora(task, opts) {
.target('dist/compiled/ora')
}
// 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'
export async function ncc_raw_body(task, opts) {
await task
Expand Down Expand Up @@ -486,6 +523,7 @@ export async function precompile(task) {
'ncc_conf',
'ncc_content_type',
'ncc_cookie',
'ncc_cssnano_simple',
'ncc_devalue',
'ncc_dotenv',
'ncc_dotenv_expand',
Expand All @@ -507,6 +545,9 @@ export async function precompile(task) {
'ncc_nanoid',
'ncc_node_fetch',
'ncc_ora',
'ncc_postcss_flexbugs_fixes',
'ncc_postcss_loader',
'ncc_postcss_preset_env',
'ncc_raw_body',
'ncc_recast',
'ncc_resolve',
Expand Down
4 changes: 4 additions & 0 deletions packages/next/types/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ declare module 'next/dist/compiled/cookie' {
import m from 'cookie'
export = m
}
declare module 'next/dist/compiled/cssnano-simple' {
import m from 'cssnano-simple'
export = m
}
declare module 'next/dist/compiled/devalue' {
import m from 'devalue'
export = m
Expand Down

0 comments on commit 755dc40

Please sign in to comment.