我正在尝试运行命令npm run build但它无法正常工作.我收到以下错误:
> typescript@1.0.0 build /Users/Prashant/Code/typescript > webpack Hash: c6dbd1eb3357da70ca81 Version: webpack 3.2.0 Time: 477ms Asset Size Chunks Chunk Names bundle.js 2.89 kB 0 [emitted] main [0] ./src/index.js 51 bytes {0} [built] [1] ./src/index.css 290 bytes {0} [built] [Failed] [1 error] ERROR in ./src/index.css Module build Failed: Unknown word (5:1) 3 | // load the styles 4 | var content = require("!!./index.css"); > 5 | if(typeof content === 'string') content = [[module.id,content,'']]; | ^ 6 | // Prepare cssTransformation 7 | var transform; 8 | @ ./src/index.js 1:0-22
我的web pack配置文件(webpack.config.js)是:
var path = require('path'); module.exports = { entry: './src/index.js',output: { path: path.resolve(__dirname,'dist'),filename: 'bundle.js' },module: { rules: [ { test: /\.css$/,use: [ 'css-loader','style-loader' ] } ] } };
我的CSS文件(index.css)是
body { color:red; }
和我的js文件index.js如下:
require("./index.css"); alert('this is my alert');
我正在尝试运行该文件,但它无法正常工作我已经检查了所有的拼写也尝试添加了很多其他的CSS,但它不起作用,你能帮我解决一下这个问题吗?