所以我的文件结构很简单。
〜
/dist
/node_modules
/src
.babelrc
index.js
package.json
webpack.config.js
我想要完成的是我正在尝试运行此命令" webpack"然后让它在我的dist文件夹中构建我的编译代码。然后我将module.exporting出来使用它。
但是,我一直遇到这个错误,说我可能需要一个适合这种文件类型的加载器。我觉得好像拥有了我需要编译的所有开发工具。
以下是我的以下webpack.config.js以及我的package.json
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"webpack": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-preset-stage-1": "^6.24.1",
"lodash": "^4.17.4",
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"jsx-loader": "^0.13.2",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.8.1"
}
}
module.exports = {
entry: [
'./src/components/select.jsx'
],
output: {
path: __dirname + /dist/,
publicPath: '/',
filename: 'form-field.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-1']
}
}]
},
resolve: {
extensions: ['.js', '.jsx']
},
devServer: {
historyApiFallback: true,
contentBase: './'
}
};
答案 0 :(得分:0)
您不允许加载器中的任何文件类型。添加test
密钥。
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-1']
}
}]