Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
apply (state, { oldColor, newColor }) {
var options = {
oldColors: [...forElementUI.getElementUISeries(oldColor)],
newColors: [...forElementUI.getElementUISeries(newColor)]
}
client.changer.changeColor(options)
}
}
apply (state, { oldColor, newColor }) {
var options = {
oldColors: [...forElementUI.getElementUISeries(oldColor)],
newColors: [...forElementUI.getElementUISeries(newColor)]
}
client.changer.changeColor(options)
}
}
apply (state, { oldColor, newColor }) {
var options = {
oldColors: [...forElementUI.getElementUISeries(oldColor)],
newColors: [...forElementUI.getElementUISeries(newColor)]
}
client.changer.changeColor(options)
}
}
export function changeThemeColor(newColor) {
var options = {
newColors: [...forElementUI.getElementUISeries(newColor), '#ff0000', '#ffff00'],
}
return client.changer.changeColor(options, Promise)
.then(t => {
curColor = newColor
localStorage.setItem('theme_color', curColor)
});
}