intoli / antd-scss-theme-plugin

A Webpack plugin for customizing Ant Design with an SCSS theme file and using Ant Design's compiled variables in SCSS files throughout your project.
https://intoli.com/blog/antd-scss-theme-plugin/
Other
202 stars 81 forks source link

Vue CLI 3 Example #48

Open btn0s opened 5 years ago

btn0s commented 5 years ago

Not sure where to start trying to get this to work with vue CLI 3.0 -- But I'm poking around and will update here if I do. Anyone else done this?

prncc commented 5 years ago

I don't have experience with this, so I can't make a more meaningful comment without looking into it, but I do plan on exposing (and slightly modifying) internal utilities so that a static theme.scss file can be easily produced with the plugin. That should make the build non-dynamic, but compatible with a wider range of tools.

PomeloMan commented 4 years ago

My solution is to add the following code in the vue.config.js file. Note: In view of #68, please ensure that the sass-loader version is below 8

module.exports = {
  ......
  configureWebpack: config => {
    config.plugins.push(new AntdScssThemePlugin('./theme.scss'))
  }
  chainWebpack(config) {
    const oneOfs = ['vue-modules', 'vue', 'normal-modules', 'normal']
    oneOfs.forEach(oneOf => {
      config.module.rule('less').oneOf(oneOf)
        .use('less-loader')
        .loader(AntdScssThemePlugin.themify('less-loader').loader)
        .options({
          sourceMap: !isProduction,
          javascriptEnabled: true
        })
      config.module.rule('sass').oneOf(oneOf)
        .use('sass-loader')
        .loader(AntdScssThemePlugin.themify('sass-loader').loader)
        .options({
          sourceMap: !isProduction,
          sassOptions: {
            indentedSyntax: true
          }
        })
      config.module.rule('scss').oneOf(oneOf)
        .use('sass-loader')
        .loader(AntdScssThemePlugin.themify('sass-loader').loader)
        .options({
          sourceMap: !isProduction,
          sassOptions: {
            indentedSyntax: true
          }
        })
    });
  }
  ......
}
jsliu27 commented 4 years ago

@PomeloMan Hi, Could you look at this problem for me? The configuration is the same as yours error in ./node_modules/_ant-design-vue@1.6.2@ant-design-vue/es/style/index.less

Module build failed (from ./node_modules/_antd-scss-theme-plugin@1.0.8@antd-scss-theme-plugin/build/dist/lib/antdLessLoader.js): Could not compile the SCSS theme file "./theme.scss" for the purpose of variable extraction. This is likely because it contains a Sass error.

@ ./node_modules/_ant-design-vue@1.6.2@ant-design-vue/es/style/index.less 4:14-300 14:3-18:5 15:22-308 @ ./node_modules/_ant-design-vue@1.6.2@ant-design-vue/es/button/style/index.js @ ./src/config/antd-component-import.ts @ ./src/main.ts @ multi ./node_modules/_webpack-dev-server@3.11.0@webpack-dev-server/client?http://192.168.31.56:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

chuyuandu commented 4 years ago

seems like that your sass file has syntax error perhaps you use some new syntax that your sass-loader don't supports