// webpack.config.js
var webpack = require("webpack");
var path = require("path");
module.exports = {
devtool: 'source-map',
context: path.resolve(__dirname, "src"),
entry: "./js/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: 'bundle.js' // 打包输出的文件
},
module: {
rules: [{
test: /\.js$/, // test 去判断是否为.js或.jsx,是的话就是进行es6和jsx的编译
exclude: /(node_modules)/,
use: [{
loader: 'babel-loader',
//配置参数;
options: {
presets: ['es2015', 'react'],
plugins: ['react-html-attrs']
}
}, ]
},
{
test: /\.css$/,
use: [{
loader: 'style-loader',
}, {
loader: 'css-loader',
options: {
modules: true,
localIdentName: '[path][name]__[local]--[hash:base64:5]'
}
}]
},
]
},
};
.miniFooter {
background: #333333;
color: #ffffff;
padding-left: 20px;
padding-top: 3px;
padding-bottom: 3px;
}
.miniFooter h1 {
font-size: 15px;
}
import React from 'react';
var footerCss = require("../../css/footer.css");//引入css
export default class CompomentFooter extends React.Component{
render(){
console.log(footerCss);
return(
<footer class={footerCss.miniFooter}>//通过var footerCss 选取footer.css中miniFooter
<h1>这里是尾部</h1>
</footer>
);
}
}