-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Migrate from kkt 4.x to 5.x #17
- Loading branch information
1 parent
c363f8b
commit 00c4d3b
Showing
6 changed files
with
7,304 additions
and
2,704 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
node_modules | ||
dist | ||
build | ||
lib | ||
cjs | ||
esm | ||
!src/lib | ||
npm-debug.log* | ||
.DS_Store | ||
|
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,66 +1,40 @@ | ||
const path = require('path'); | ||
const pkg = require('./package.json'); | ||
import path from 'path'; | ||
|
||
process.env.APPSRC = path.resolve(process.cwd(), 'website'); | ||
export const loaderOneOf = [ | ||
require.resolve('@kkt/loader-less') | ||
]; | ||
|
||
module.exports = { | ||
plugins: [ | ||
require.resolve('@kkt/plugin-less'), | ||
], | ||
babelInclude: [path.resolve(process.cwd(), 'src')], | ||
// Modify the webpack config | ||
config: (conf, { dev, env }, webpack) => { | ||
if (env === 'prod') { | ||
conf = { | ||
...conf, | ||
optimization: { | ||
...conf.optimization, | ||
// https://webpack.js.org/plugins/split-chunks-plugin/ | ||
splitChunks: { | ||
chunks: 'async', | ||
minSize: 30000, | ||
minChunks: 2, | ||
maxAsyncRequests: 5, | ||
maxInitialRequests: 3, | ||
automaticNameDelimiter: '~', | ||
name: true, | ||
cacheGroups: { | ||
vendors: { | ||
test: /[\\/]node_modules[\\/]/, | ||
priority: -10 | ||
}, | ||
default: { | ||
minChunks: 2, | ||
priority: -20, | ||
reuseExistingChunk: true | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
// 获取 React CodeMirror 版本 | ||
conf.plugins.push( | ||
new webpack.DefinePlugin({ | ||
VERSION: JSON.stringify(pkg.version), | ||
}) | ||
); | ||
// 解析 Markdown 文件 | ||
conf.module.rules = [ | ||
...conf.module.rules, | ||
{ | ||
test: /\.md$/, | ||
loader: 'raw-loader', | ||
}, | ||
]; | ||
export const moduleScopePluginOpts = [ | ||
path.resolve(process.cwd(), 'README.md') | ||
]; | ||
|
||
if (env === 'prod') { | ||
// 生产模式下更改的 webpack 配置 | ||
conf.entry[0] = path.resolve(process.cwd(), 'website'); | ||
conf.output.publicPath = ''; | ||
} else { | ||
conf.entry[1] = path.resolve(process.cwd(), 'website', 'index.js'); | ||
export default (conf, opts, webpack) => { | ||
const pkg = require(path.resolve(process.cwd(), 'package.json')); | ||
// Webpack parses md file text | ||
conf.module.rules.map((item) => { | ||
if (item.oneOf) { | ||
item.oneOf.unshift({ | ||
test: /\.md$/, | ||
use: require.resolve('raw-loader'), | ||
}); | ||
} | ||
return conf; | ||
}, | ||
}; | ||
return item; | ||
}); | ||
|
||
// Get the project version. | ||
conf.plugins.push( | ||
new webpack.DefinePlugin({ | ||
VERSION: JSON.stringify(pkg.version), | ||
}) | ||
); | ||
// 解析 Markdown 文件 | ||
conf.module.rules = [ | ||
...conf.module.rules, | ||
{ | ||
test: /\.md$/, | ||
loader: 'raw-loader', | ||
}, | ||
]; | ||
conf.output = { ...conf.output, publicPath: './' } | ||
return conf; | ||
} |
Oops, something went wrong.