嗨,我正在尝试使用webpack 4.26.1来为Angularjs 1.x项目编译我的包,但是我得到了
./src/services-preparing.service.js 10:19中的错误 模块解析失败:意外的令牌(10:19) 您可能需要适当的加载程序来处理此文件类型。
| export default class ServicesPreparingService {
|
> static $inject = ['loginService', 'productService'];
|
| constructor(company) {
我的webpack配置是
const path = require("path");
const ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: {
app: ["babel-polyfill","./src/app.js"]
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
},
devServer: {
contentBase: path.join("dist"),
compress: false,
port: 2222,
hot:false
},
stats:"errors-only",
module:{
rules:[
{
test: /\.js$/,
exclude: /node_modules/,
include: path.resolve(__dirname,"./src/scripts/"),
loader: 'babel',
options: {
presets: ['es2015-loose', 'stage-0'],
plugins: ['transform-proto-to-assign']
}
}]
},
plugins: [
new ExtractTextPlugin('style.css')
],
};
我也遇到过类似的问题,但它们主要是为了做出反应或某些人使用了错误的Webpack配置。
我只调用 webpack 首先进行编译,这会引发此错误。非常感谢您的支持