Giter Club home page Giter Club logo

js-conditional-compile-loader's People

Contributors

dependabot[bot] avatar hzsrc avatar wenlz123 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

js-conditional-compile-loader's Issues

配置项目遇到很多错误,请帮忙看看

    module: {
      rules: [
        { test: /\.m4a$/, use: 'raw-loader' },
        {
          test: /\.vue$/,
          use: ['vue-loader', conditionalCompiler],
        },
        {
          test: /\.js$/,
          include: [resolve('src'), resolve('test')],
          use: [
            //step-2
            'babel-loader?cacheDirectory',
            //step-1
            conditionalCompiler,
          ],
        },
      ],
    },
  },

image

options object is not refreshed upon multiple calls

Hi, I'm trying to get compiled different versions depending on some runtime values and I found this plugin very usefull, but I think I have found a bug.
When using this plugin on several webpack config objects, the output bundles always match the first of the passed objects.

For example this config object was always creating bundles matching the first of the objects in the array (page1):

module.exports = [
  {
    entry: {
      page1: "./src/index.js",
    },
    ...
    module: {
      rules: [       
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: false,
            hero: true,
            slider: false,
          },
        },
      ],
    },
  },
  {
    entry: {
      page2: "./src/index.js",
    },
    ...
    module: {
      rules: [
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: false,
            hero: true,
            slider: true,
          },
        },
      ],
    },
  },
  {
    entry: {
      page3: "./src/index.js",
    },
    ...
    module: {
      rules: [
        {
          loader: "js-conditional-compile-loader",
          options: {
            gallery: true,
            hero: false,
            slider: false,
          },
        },
      ],
    },
  },
];

After debugging a little the code of the loader, I found that in the index.js file, the options variable is defined outside of the exported function, it's always taking the value of the first call done to it, and not taking the passed config on succesive executions. This gets solved by removing the if on line #7.

Hope you find this useful.

Cheers!

属性名的方式可以使用多个属性吗

option如下配置的话,可以在代码里设置多个条件编译吗

{
ALI:true,
TENCENT: true
}


/* IFTRUE_ALI */
console.log('ali')
/* FITRUE_ALI */


/* IFTRUE_TENCENT */
console.log('TENCENT')
/* FITRUE_TENCENT*/

JSON支持

请问json的条件编译是不支持吗?

希望可以支持嵌套

/* IFDEBUG */

/* IFTRUE_envTest */
import xx from 'test.debug.js'
/* FITRUE_envTest */

/* IFTRUE_envBeta */
import xx from 'beta.debug.js'
/* FITRUE_envBeta */

/* FIDEBUG */

The conditions do not work "automatically"

Hello,

Thanks for the tool that is a great way to deal with conditional rendering.
We use the conditional rendering in a Vue project to conditionally generate some parts in Vue components and in javascript files.

We have an issue though to generate the conditional rendering "automatically": when we want to switch from one condition to the other, compiling the code again (using npm run serve --optionX) will not make a difference. To apply the condition, we have to make a change in each files containing the directive /*IFTRUE_XXX (a space after the directive for example), then save. The next compilation will produce the code as expected.

I'm not sure if that's a bug or a problem from our setup?

Here is the extract our vue.config.json

module.exports = {
    /* IFTRUE_isMicrobit */
    configureWebpack: {
        devtool: "source-map",
        plugins: [
            new MoveAssetsPlugin({
                clean: true,
                patterns: [
                    {
                        from: "dist/pythonLib",
                        to: "dist/",
                    },
                ],
            }),
        ],
    },
    /* FITRUE_isMicrobit */   
    chainWebpack: (config) => {
        config.module
            .rule("conditionalCompilerVue")
            .test(/\.vue$/)
            .use("vue-loader")
            .loader("js-conditional-compile-loader")
            .options( {
                isPurePython: process.env.npm_config_python,
                isMicrobit: process.env.npm_config_microbit,
            });
        config.module
            .rule("conditionalCompilerTS")
            .test(/\.ts$/)
            .use("vue-loader")
            .loader("js-conditional-compile-loader")
            .options( {
                isPurePython: process.env.npm_config_python,
                isMicrobit: process.env.npm_config_microbit,
            });
    },
    publicPath: (process.env.npm_config_python)?"/editor/":"/microbit/",
    pluginOptions: {
        i18n: {
            locale: "en",
            fallbackLocale: "en",
            localeDir: "localisation",
            enableInSFC: false,
        },
    },
}

Thank you so much for your help - if any other file is needed to explore this issue, please let me know

路由单独拆分后如何合并的问题

你好,有个问题请教一下,比如页面有20个路由,我设置了默认打包只打15个,另外5个单独打包(单独的没有入口所以无法独立运行),如果我在部署的时候另一个环境需要修改这五个路由里面的某处(全部打包太麻烦,所以修改具体地方,打包那五个路由模块即可),如何将两个打包后的文件组装起来了?因为生成后的哈希值不可控,默认没有那五个路由,打完之后需要手动去修改路由以及那五个模块,尝试了很多方案目前还没有解决

Not working on index.html

Hi,

I am developing something in Vue and I want conditional complilation at the entry point for my application - i.e. index.html.
However, js-conditional-compile-loader does not seem to be working there.

Can you help me please?

对SourceMap的影响

先谢谢作者提供的插件,解决了我的一些实际问题。

今天在调试时发现,启用之后,SourceMap定位错误的问题,因为插件具体技术细节不了解,所以请作者判断下,如果有影响,又是否有解决的办法,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.