我对前端相当陌生,我一直在尝试学习 webpack。我在使用 Extract-Text-Webpack-Plugin 时遇到了一些我似乎无法弄清楚的问题。我将不胜感激有关此主题的任何帮助。此外,欢迎任何建议/提示!
警告/错误
./~/chokidar/lib/fsevents-handler.js 中的警告模块未找到:错误:无法解析 C:\Git\JNJ.Web\src\JNJ.Web.UI\client\node_modules\chokidar 中的模块“fsevents” \lib@./~/chokidar/lib/fsevents-handler.js 7:17-36
(webpack)/~/constants-browserify/constants.json 中的错误模块解析失败:C:\Users\christian\AppData\Roaming\npm\node_modules\webpack\node_modules\constants-browserify\constants.json 意外令牌(2: 12) 你可能需要一个合适的加载器来处理这个文件类型。SyntaxError: Unexpected token (2:12) at Parser.pp$4.raise (C:\Users\christian\AppData\Roaming\npm\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15) 在 Parser .pp.unexpected (C:\Users\christian\AppData\Roaming\npm\node_modules\webpack\node_modules\acorn\dist\acorn.js:603:10) 在 Parser.pp.semicolon (C:\Users\christian\ AppData\Roaming\npm\node_modules\webpack\node_modules\acorn\dist\acorn.js:581:61) 在 Parser.pp$1.parseExpressionStatement (C:\Users\christian\AppData\Roaming\npm\node_modules\webpack\node_modules \acorn\dist\acorn.js:966:
包.json
{
"name": "OrderEze.CRM",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "",
"watch": "webpack-dev-server webpack.config.js --progress --colors --watch",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "OrderEze",
"license": "ISC",
"dependencies": {
"babel-core": "6.7.4",
"babel-loader": "6.2.4",
"babel-preset-es2015": "6.6.0",
"babel-preset-react": "6.5.0",
"babel-preset-stage-1": "6.5.0",
"classnames": "2.2.0",
"css-loader": "0.19.0",
"extract-text-webpack-plugin": "0.8.2",
"react": "15.4.1",
"react-dom": "15.4.1",
"style-loader": "0.12.4",
"webpack": "1.12.13"
},
"devDependencies": {
"babel-eslint": "7.0.0",
"eslint": "3.12.2",
"eslint-config-airbnb": "12.0.0",
"eslint-plugin-import": "1.16.0",
"eslint-plugin-jsx-a11y": "2.2.2",
"eslint-plugin-react": "6.3.0",
"stylelint": "7.3.1"
}
}
webpack.config.js
var aliases = require('./task-ticket/aliases.js');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
entry: './task-ticket/index.jsx',
output: {
path: path.join(__dirname, '/build'),
filename: 'bundle.js'
},
module: {
loaders: [{
exclude: /node_modules/,
test: /\.jsx?$/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react', 'stage-1']
}
},
{
test: /\.css?$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
}]
},
plugins: [
new ExtractTextPlugin('style.css')
],
node: {
fs: 'empty'
},
resolve: {
root: path.resolve(__dirname),
alias: aliases,
extensions: ['', '.js', '.jsx', '.css']
}
};