-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa218f9
commit fa04cac
Showing
10 changed files
with
185 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const cssLoaderConfig = require('@zeit/next-css/css-loader-config') | ||
|
||
module.exports = (nextConfig = {}) => { | ||
return Object.assign({}, nextConfig, { | ||
webpack(config, options) { | ||
if (!options.defaultLoaders) { | ||
throw new Error( | ||
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade' | ||
) | ||
} | ||
|
||
const { dev, isServer } = options | ||
const { cssModules, cssLoaderOptions, postcssLoaderOptions } = nextConfig | ||
|
||
options.defaultLoaders.css = cssLoaderConfig(config, { | ||
extensions: ['css'], | ||
cssModules, | ||
cssLoaderOptions, | ||
postcssLoaderOptions, | ||
dev, | ||
isServer | ||
}) | ||
|
||
config.module.rules.push({ | ||
test: /\.css$/, | ||
use: Object.assign(options.defaultLoaders.css, { cssModules: true }), | ||
exclude: /node_modules/ | ||
}) | ||
|
||
config.module.rules.push({ | ||
test: /\.css$/, | ||
use: Object.assign(options.defaultLoaders.css, { cssModules: false }), | ||
include: /node_modules/ | ||
}) | ||
|
||
if (typeof nextConfig.webpack === 'function') { | ||
return nextConfig.webpack(config, options) | ||
} | ||
|
||
return config | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
const cssLoaderConfig = require('@zeit/next-css/css-loader-config') | ||
|
||
module.exports = (nextConfig = {}) => { | ||
return Object.assign({}, nextConfig, { | ||
webpack(config, options) { | ||
if (!options.defaultLoaders) { | ||
throw new Error( | ||
'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade' | ||
) | ||
} | ||
|
||
const { dev, isServer } = options | ||
const { | ||
cssModules, | ||
cssLoaderOptions, | ||
postcssLoaderOptions, | ||
lessLoaderOptions = {} | ||
} = nextConfig | ||
|
||
options.defaultLoaders.less = cssLoaderConfig(config, { | ||
extensions: ['less'], | ||
cssModules, | ||
cssLoaderOptions, | ||
postcssLoaderOptions, | ||
dev, | ||
isServer, | ||
loaders: [ | ||
{ | ||
loader: 'less-loader', | ||
options: lessLoaderOptions | ||
} | ||
] | ||
}) | ||
|
||
// config.module.rules.push({ | ||
// test: /\.less$/, | ||
// use: options.defaultLoaders.less | ||
// }) | ||
|
||
config.module.rules.push({ | ||
test: /\.less$/, | ||
use: cssLoaderConfig(config, { | ||
extensions: ['less'], | ||
cssModules: true, | ||
cssLoaderOptions, | ||
postcssLoaderOptions, | ||
dev, | ||
isServer, | ||
loaders: [ | ||
{ | ||
loader: 'less-loader', | ||
options: lessLoaderOptions | ||
} | ||
] | ||
}), | ||
exclude: /node_modules/ | ||
}) | ||
|
||
config.module.rules.push({ | ||
test: /\.less$/, | ||
use: cssLoaderConfig(config, { | ||
extensions: ['less'], | ||
cssModules: false, | ||
cssLoaderOptions, | ||
postcssLoaderOptions, | ||
dev, | ||
isServer, | ||
loaders: [ | ||
{ | ||
loader: 'less-loader', | ||
options: lessLoaderOptions | ||
} | ||
] | ||
}), | ||
include: /node_modules/ | ||
}) | ||
|
||
if (typeof nextConfig.webpack === 'function') { | ||
return nextConfig.webpack(config, options) | ||
} | ||
|
||
return config | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/// <reference types="next/types/global" /> | ||
|
||
declare module '*.png' | ||
declare module '*.less' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
const withLess = require('@zeit/next-less') | ||
const withLess = require('./config/withLess') | ||
const withCss = require('./config/withCSS') | ||
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin') | ||
|
||
module.exports = withLess({ | ||
lessLoaderOptions: { | ||
javascriptEnabled: true | ||
}, | ||
webpack(config) { | ||
config.module.rules = [ | ||
...config.module.rules, | ||
{ | ||
test: /\.css$/, | ||
use: ['style-loader', 'css-loader'] | ||
}, | ||
{ | ||
test: /\.ttf$/, | ||
use: ['file-loader?outputPath=static'] | ||
}, | ||
{ | ||
test: /\.(gif|png|jpe?g|svg)$/i, | ||
use: ['url-loader'] | ||
} | ||
] | ||
module.exports = withCss( | ||
withLess({ | ||
lessLoaderOptions: { | ||
javascriptEnabled: true | ||
}, | ||
webpack(config) { | ||
config.module.rules = [ | ||
...config.module.rules, | ||
{ | ||
test: /\.ttf$/, | ||
use: ['file-loader?outputPath=static'] | ||
}, | ||
{ | ||
test: /\.(gif|png|jpe?g|svg)$/i, | ||
use: ['url-loader'] | ||
} | ||
] | ||
|
||
config.plugins.push( | ||
new MonacoWebpackPlugin({ | ||
publicPath: '_next', | ||
filename: `static/[name].worker.js` | ||
}) | ||
) | ||
config.plugins.push( | ||
new MonacoWebpackPlugin({ | ||
publicPath: '_next', | ||
filename: `static/[name].worker.js` | ||
}) | ||
) | ||
|
||
return Object.assign(config, { | ||
target: 'electron-renderer', | ||
devtool: 'cheap-module-source-map', | ||
plugins: config.plugins.filter(p => { | ||
return p.constructor.name !== 'UglifyJsPlugin' | ||
return Object.assign(config, { | ||
target: 'electron-renderer', | ||
devtool: 'cheap-module-source-map', | ||
plugins: config.plugins.filter(p => { | ||
return p.constructor.name !== 'UglifyJsPlugin' | ||
}) | ||
}) | ||
}) | ||
}, | ||
useFileSystemPublicRoutes: false, | ||
exportPathMap() { | ||
return { | ||
'/main': { page: '/main' } | ||
}, | ||
useFileSystemPublicRoutes: false, | ||
exportPathMap() { | ||
return { | ||
'/main': { page: '/main' } | ||
} | ||
} | ||
} | ||
}) | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import React from 'react' | ||
import SearchInput from './SearchInput' | ||
import UserAvatar from './UserAvatar' | ||
import './index.less' | ||
import $style from './index.less' | ||
|
||
export default class MainHeader extends React.Component { | ||
render() { | ||
return ( | ||
<div className='MainHeader'> | ||
render() { | ||
return ( | ||
<div className={$style.MainHeader}> | ||
<SearchInput /> | ||
<UserAvatar /> | ||
</div> | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters