Dva: LESS生成后的class名称代码怎么会加随机数?能去掉吗?

Created on 21 Oct 2016  ·  2Comments  ·  Source: dvajs/dva

.Footer {
position: absolute;
bottom: 0;
width: 100%;
/* Set the fixed height of the footer here _/
height: 48px;
}
生成后的代码怎么会加随机数?能去掉吗?
.Footer___3uj4E {
position: absolute;
bottom: 0;
width: 100%;
/_ Set the fixed height of the footer here */
height: 48px;
}

Most helpful comment

阮一峰的文章里面也有解释:http://www.ruanyifeng.com/blog/2016/06/css_modules.html

webpack.config.js

module.exports = {
  entry: __dirname + '/index.js',
  output: {
    publicPath: '/',
    filename: './bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'stage-0', 'react']
        }
      },
      {
        test: /\.css$/,
        loader: "style-loader!css-loader?modules"
      },
    ]
  }
};

上面代码中,关键的一行是style-loader!css-loader?modules,它在css-loader后面加了一个查询参数modules,表示打开 CSS Modules 功能。

All 2 comments

@shenggen1987 这个是因为dva中用了css modules,具体文档这里有:https://github.com/dvajs/dva-knowledgemap#css-modules

阮一峰的文章里面也有解释:http://www.ruanyifeng.com/blog/2016/06/css_modules.html

webpack.config.js

module.exports = {
  entry: __dirname + '/index.js',
  output: {
    publicPath: '/',
    filename: './bundle.js'
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'babel',
        query: {
          presets: ['es2015', 'stage-0', 'react']
        }
      },
      {
        test: /\.css$/,
        loader: "style-loader!css-loader?modules"
      },
    ]
  }
};

上面代码中,关键的一行是style-loader!css-loader?modules,它在css-loader后面加了一个查询参数modules,表示打开 CSS Modules 功能。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kpaxqin picture kpaxqin  ·  3Comments

oldfeel picture oldfeel  ·  3Comments

mclouvem picture mclouvem  ·  4Comments

huyawei picture huyawei  ·  3Comments

BenAnn picture BenAnn  ·  3Comments