[英]SCRIPT1003: Expected ':'
我知道這個標題有很多問題
但是我有這個
腳本1003:預期的':'(1,78)
啟動網站時
我在項目中使用webpack和打字稿
這是tsconfig
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"typeRoots": [
"./node_modules/@types"
],
"types": [ "jquery", "accounting","js-cookie" ],
"lib": ["es6", "dom"],
"allowSyntheticDefaultImports": true,
"module": "es6",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"exclude": [
"**/*.spec.ts",
"node_modules",
"vendor",
"public"
],
"compileOnSave": false
}
這是用於webpack的enviroment.js
const { environment } = require("@rails/webpacker");
const { resolve } = require("path");
const webpack = require("webpack");
const typescript = require("./loaders/typescript");
const HoneybadgerSourceMapPlugin = require("@honeybadger-io/webpack");
const revision = process.env.GIT_COMMIT || "master";
const apiKey = "***********";
const assetsUrl = "*/packs";
environment.plugins.prepend("Provide", new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
jquery: "jquery",
"window.Tether": "tether",
})
);
if (process.env.NODE_ENV === "production") {
environment.plugins.prepend(
"HoneybadgerSourceMap",
new HoneybadgerSourceMapPlugin({
apiKey: apiKey,
assetsUrl: assetsUrl,
silent: false,
ignoreErrors: false,
revision: revision
})
);
}
const config = environment.toWebpackConfig();
config.resolve.alias = {
jquery: "jquery/src/jquery",
};
config.externals = {
gon: "gon"
};
environment.loaders.get("sass").use.find((item) => item.loader === "sass-loader").options.includePaths = [resolve("app", "javascript", "themes")];
environment.loaders.append("typescript", typescript);
module.exports = environment;
行(1,78)代碼
var o = e[i] ={
i,
l: !1,
exports :{}
};
但這似乎是webpack的自動生成的代碼。
哪里有麻煩,我該如何解決?
我想幾年還晚了,但我也遇到了這個錯誤。
解決方法是添加
if (environment.plugins.getIndex('UglifyJs') !== -1) {
const plugin = environment.plugins.get('UglifyJs');
plugin.options.uglifyOptions.ecma = 5;
}
到您的environment.js
希望對別人有幫助
在這里我找到了解決方案: https : //github.com/rails/webpacker/issues/1235
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.