Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境 sourcemap 不包含列信息
.when(process.env.NODE_ENV === 'development',
config => config.devtool('cheap-source-map')
)
// 预览环境构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// markdown
config.module
.rule('md')
.test(/\.md$/)
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
config => config.devtool('source-map')
) // 在WebStorm中调试需要source-map
// 预览环境构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// markdown
config.module
.rule('md')
.test(/\.md$/)
} else if (percentage === 1) {
// eslint-disable-next-line no-console
console.log(chalk.green('\nwebpack: bundle build is now finished.'));
if (processTimer) {
clearInterval(processTimer);
}
}
}
}),
new FriendlyErrorsWebpackPlugin(),
new webpack.ProvidePlugin({
Choerodon: isDev
? join(process.cwd(), `node_modules/@choerodon/${masterName}/lib/containers/common`)
: join(__dirname, `../../../${masterName}/lib/containers/common`),
}),
new ThemeColorReplacer({
fileName: cssColorFileName,
matchColors: [
colorPalette(baseColor, 1),
colorPalette(baseColor, 2),
colorPalette(baseColor, 3),
colorPalette(baseColor, 4),
colorPalette(baseColor, 5),
baseColor,
colorPalette(baseColor, 7),
colorPalette(baseColor, 8),
colorPalette(baseColor, 9),
colorPalette(baseColor, 10),
'#303f9f', // 左上角颜色
'140, 158, 255, 0.12', // menu-item背景
'140, 158, 255, 0.16', // 左侧菜单menu-item背景
],
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
ENV_CONFIG: JSON.stringify(process.env.ENV_CONFIG),
}
}),
// 将theme-changed.scss应用到element-ui,供babel-plugin-component按需加载
new JoinFileContentPlugin({
file: 'node_modules/element-theme-chalk/src/common/var.scss',
prependFile: 'src/css/element-theme/theme-changed.scss'
}),
//生成仅包含颜色的替换样式(主题色等)
new ThemeColorReplacer({
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(appConfig.themeColor), //element-ui主色系列
'#0cdd3a', //自定义颜色
'#c655dd',
],
changeSelector: forElementUI.changeSelector,
isJsUgly: config.isBuild,
// injectCss: false,
// resolveCss(resultCss) { // optional. Resolve result css code as you wish.
// return resultCss + youCssCode
// }
})
],
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
config => config.devtool('source-map')
) // 在WebStorm中调试需要source-map
// 预览环境构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// markdown
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境
.when(process.env.NODE_ENV === 'development',
// sourcemap不包含列信息
config => config.devtool('cheap-source-map')
)
// TRAVIS 构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
ENV_CONFIG: JSON.stringify(process.env.ENV_CONFIG),
}
}),
// 将theme-changed.scss应用到element-ui,供babel-plugin-component按需加载
new JoinFileContentPlugin({
file: 'node_modules/element-theme-chalk/src/common/var.scss',
prependFile: 'src/css/element-theme/theme-changed.scss'
}),
//生成仅包含颜色的替换样式(主题色等)
new ThemeColorReplacer({
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(appConfig.themeColor), //element-ui主色系列
'#0cdd3a', //自定义颜色
'#c655dd',
],
changeSelector: forElementUI.changeSelector,
isJsUgly: isBuild,
// injectCss: false,
// resolveCss(resultCss) { // optional. Resolve result css code as you wish.
// return resultCss + youCssCode
// }
})
]
if (!isBuild) {
plugins.push(require('../build/svg2font.js'))
plugins.push(new webpack.SourceMapDevToolPlugin({
filename: `${config.sourceMapPath}/[filebase].map`,
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#prefetch
* https://cli.vuejs.org/zh/guide/html-and-static-assets.html#preload
* 而且预渲染时生成的 prefetch 标签是 modern 版本的,低版本浏览器是不需要的
*/
config.plugins
.delete('prefetch')
.delete('preload')
// 解决 cli3 热更新失效 https://github.com/vuejs/vue-cli/issues/1559
config.resolve
.symlinks(true)
config
.plugin('theme-color-replacer')
.use(ThemeColorReplacer, [{
fileName: 'css/theme-colors.[contenthash:8].css',
matchColors: [
...forElementUI.getElementUISeries(process.env.VUE_APP_ELEMENT_COLOR) // Element-ui主色系列
],
externalCssFiles: [ './node_modules/element-ui/lib/theme-chalk/index.css' ], // optional, String or string array. Set external css files (such as cdn css) to extract colors.
changeSelector: forElementUI.changeSelector
}])
config
// 开发环境 sourcemap 不包含列信息
.when(process.env.NODE_ENV === 'development',
config => config.devtool('cheap-source-map')
)
// 预览环境构建 vue-loader 添加 filename
.when(process.env.VUE_APP_SCOURCE_LINK === 'TRUE',
VueFilenameInjector(config, {
propName: process.env.VUE_APP_SOURCE_VIEWER_PROP_NAME
})
)
// markdown
changeColor(color?: string): Promise {
if (!color) {
return Promise.resolve();
}
const options = {
// new colors array, one-to-one corresponde with `matchColors`
newColors: this.getAntdSerials(color),
changeUrl(cssUrl: string): string {
// while router is not `hash` mode, it needs absolute path
return `/${cssUrl}`;
},
};
return client.changer.changeColor(options, Promise);
},
};
changeColor(color?: string): Promise {
if (!color) {
return Promise.resolve();
}
const options = {
// new colors array, one-to-one corresponde with `matchColors`
newColors: this.getAntdSerials(color),
changeUrl(cssUrl: string): string {
// while router is not `hash` mode, it needs absolute path
return `/${cssUrl}`;
},
};
return client.changer.changeColor(options, Promise);
},
};