1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | const path = require( 'path' ); const HTMLWebpackPlugin = require( 'html-webpack-plugin' ); module.exports = { entry: { app: path.join(__dirname, 'src/app.js' ), }, output: { filename: '[name].bundle.js' , chunkFilename: '[name].chunk.js' , path: path.join(__dirname, 'dist' ), // publicPath: "dist", }, devServer: { contentBase: './dist' , // hot: true, }, devtool: 'inline-source-map' , module: { rules: [ { test: /\.css$/, use: [ { loader: 'style-loader/useable' , }, { loader: 'css-loader' , }, ], exclude: /node_modules/, }, { test: /\.(js|jsx)$/, use: 'babel-loader' , exclude: /node_modules/, }, ], }, plugins: [ new HTMLWebpackPlugin({ template: path.join(__dirname, 'src/index.html' ), }), ], }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import React, { Component } from 'react' ; import style from './index.css' ; style.use(); let flag = true ; setInterval(() => { // console.log('f', style) flag ? style.ref() : style.unref(); flag = !flag; }, 1000); class Test extends Component { render() { return (<div className= "test" > this is div </div>); } } export default Test; |
这里有什么问题吗,我use/ref都不行