我刚刚开始使用一个升级的模板将我的aspdotnet core Aurelia项目升级到3.0,该模板是我用来创建项目的模板。
我把我的文件(在以前的项目工作)到这个新版本,我已经结束了一堆错误,从webpack的第一个是在标题中概述。
网页包也已升级。这是我收到的第一个错误。。
ERROR in ./ClientApp/public/public/public.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
> @media (max-width: 767px) {
| /* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
| .body-content {
@ ./ClientApp/public/public/public.html
@ ./ClientApp/boot.ts
@ ./node_modules/aurelia-webpack-plugin/runtime/empty-entry.js
@ multi aurelia-webpack-plugin/runtime/empty-entry aurelia-webpack-plugin/runtime/pal-loader-entry es6-promise/auto aurelia-bootstrapper
发现了与此相同的问题,结果发现我没有替身,所以是另外一个问题。。
我还检查了这个标题非常相似的问题,但我相信webpack文件可以,因为它适用于基本的aurelia文件。。
这个问题虽然类似,但有一个稍微(看起来)的设置,因为它有一个webpack dev文件。这是我的包裹。顶部带有脚本的json:
{
"name": "Jobsledger.API",
"private": true,
"version": "0.0.0",
"scripts": {
"lint": "tslint --project tsconfig.json",
"webpack:Debug": "webpack --mode development",
"webpack:Release": "webpack --mode production",
"webpack:watch": "webpack --mode development --watch"
},
"devDependencies": {
"aurelia-animator-css": "^1.0.4",
"aurelia-api": "^3.2.1",
"aurelia-binding": "2.3.1",
"aurelia-bootstrap": "^0.1.20",
"aurelia-bootstrapper": "^2.3.3",
"aurelia-dialog": "^2.0.0-rc.5",
"aurelia-event-aggregator": "^1.0.3",
"aurelia-fetch-client": "^1.8.2",
"aurelia-mask": "^2.0.1",
"aurelia-pal": "^1.8.2",
"aurelia-router": "^1.7.1",
"aurelia-templating": "^1.10.2",
"aurelia-validation": "^1.4.0",
"aurelia-webpack-plugin": "^4.0.0",
"au-table": "^0.1.14",
"awesome-typescript-loader": "^5.2.1",
"bootstrap": "^4.3.1",
"clean-webpack-plugin": "^2.0.2",
"css-loader": "^2.1.1",
"es6-promise": "^4.2.6",
"fetch": "^1.1.0",
"file-loader": "^3.0.1",
"font-awesome": "^4.7.0",
"html-loader": "^0.5.5",
"html-webpack-plugin": "^3.2.0",
"isomorphic-fetch": "^2.2.1",
"jquery": "^3.4.1",
"mini-css-extract-plugin": "^0.6.0",
"node-sass": "^4.12.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"popper.js": "^1.15.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"tether": "^1.4.6",
"tslint": "^5.16.0",
"ts-loader": "^6.0.1",
"typescript": "^3.4.5",
"url-loader": "^1.1.2",
"velocity-animate": "^2.0.5",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.2"
}
}
我想我可能需要修改网页包文件,就像上面提到的那样。。在显示网页包文件之前,这里是公开的。导致第一个错误的css文件:
@media (max-width: 767px) {
/* On small screens, the nav menu spans the full width of the screen. Leave a space for it. */
.body-content {
padding-top: 50px;
}
}
现在这是网页。配置。js文件
const path = require("path");
const webpack = require("webpack");
const { AureliaPlugin, ModuleDependenciesPlugin, GlobDependenciesPlugin } = require("aurelia-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");
const bundleOutputDir = "./wwwroot/dist";
module.exports = (env, argv) => {
if ((!argv || !argv.mode) && process.env.ASPNETCORE_ENVIRONMENT === "Development") {
argv = { mode: "development" };
}
console.log("mode =", argv.mode);
const isDevBuild = argv.mode !== "production";
const cssLoaders = ["css-loader", "postcss-loader"];
const scssLoaders = [...cssLoaders, "sass-loader"];
return [{
target: "web",
mode: isDevBuild ? "development" : "production",
entry: { "app": ["es6-promise/auto", "aurelia-bootstrapper"] },
resolve: {
extensions: [".ts", ".js"],
modules: ["ClientApp", "node_modules"]
},
output: {
path: path.resolve(bundleOutputDir),
// Asp.Net JavaScriptServices does not tolerate "/" in public path, see https://github.com/aspnet/JavaScriptServices/issues/1495
publicPath: "dist/",
filename: "[name].[hash].js",
chunkFilename: "[name].[chunkhash].js",
pathinfo: false
},
module: {
rules: [
{ test: /\.(woff|woff2|png|eot|ttf|svg)(\?|$)/, use: { loader: "url-loader", options: { limit: 1, publicPath: "./" } } },
{ test: /\.ts$/i, include: [/ClientApp/], loader: "ts-loader" },
{ test: /\.html$/i, use: "html-loader" },
{ test: /\.css$/i, include: [/node_modules/], issuer: /\.html$/i, use: cssLoaders },
{ test: /\.css$/i, include: [/node_modules/], exclude: [/bootstrap.css$/, /font-awesome.css$/], issuer: [{ not: [{ test: /\.html$/i }] }], use: ["style-loader", ...cssLoaders] },
{ test: /\.css$/, include: [/bootstrap.css$/, /font-awesome.css$/], use: [{ loader: MiniCssExtractPlugin.loader }, ...cssLoaders] },
{ test: /\.scss$/i, issuer: /(\.html|empty-entry\.js)$/i, use: scssLoaders },
{ test: /\.scss$/i, issuer: /\.ts$/i, use: ["style-loader", ...scssLoaders] }
]
},
optimization: {
splitChunks: {
chunks: "all",
// comment the following to avoid creatin a separate bundle for each npm module
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
// get the name. E.g. node_modules/packageName/not/this/part.js
// or node_modules/packageName
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
// npm package names are URL-safe, but some servers don't like @ symbols
return `npm.${packageName.replace('@', '')}`;
}
}
}
}
},
devtool: isDevBuild ? "source-map" : false,
performance: {
hints: false
},
plugins: [
new CleanWebpackPlugin(),
new webpack.DefinePlugin({ IS_DEV_BUILD: JSON.stringify(isDevBuild) }),
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery", "window.jQuery": "jquery" }),
new HtmlWebpackPlugin({ template: 'index.ejs', filename: "../../wwwroot/index.html", inject: false, metadata: {}, alwaysWriteToDisk: true }),
new AureliaPlugin({ aureliaApp: "boot" }),
new GlobDependenciesPlugin({ "boot": ["ClientApp/**/*.{ts,html}"] }),
new ModuleDependenciesPlugin({}),
new MiniCssExtractPlugin({
filename: "[name].[hash].css",
chunkFilename: "[name].[chunkhash].css"
})
],
devServer: {
contentBase: "wwwroot/",
compress: true,
writeToDisk: true,
hot: false
}
}];
};
对于所有其他错误,我基本上得到了同样的错误:
You may need an appropriate loader to handle this file type.
所以它是某种类型的装载机...
我不确定我需要对网页文件做什么才能使其正常工作。。
CSS媒体查询的语法错误。
你需要这样写:
@media {thing-you-want-to-query} and {case} {
.body-content {
padding-top: 50px;
}
在您的情况下,它将是屏幕:
@media screen and (max-width: 767px) {
.body-content {
padding-top: 50px;
}
我用Webpack创建了我的项目,并在开发中使用了Vue.js,但是我不能注入
我正面临下面的错误。我尝试了所有的解决方案在其他文章中提到的相同的问题。但没有运气。请帮帮忙。 下面是我的档案。 package.json webpack.conf.js 应用程序JS index.js
我正在尝试使用Webpack构建一个简单的React应用程序,但是在从Webpack dev服务器运行时,我遇到以下错误: 以下是我的Webpack.config.js文件内容: app.js文件内容从“React”导入React从“React dom”导入ReactDOM从“React dom”导入{Switch,BrowserRouter,Route}从“React router dom”导入
我得到下面的错误,我不明白为什么我认为应该有一些与巴贝尔。我使用web开发服务器和babel。它在反应。 我的Webconfig文件如下所示: 我的package.json文件如下所示: 我错过了什么?这与path.resolve有关吗?
未捕获错误:模块分析失败:g:\demo\my-ng2-admin\my-ng2-admin\my-ng2-admin\node_module\awesome-typescript-loader\dist\entry.js?{“configfilename”:“g:\demo\my-ng2-admin\my-ng2-admin\my-ng2-admin\src\tsconfig.json”}!g:
我正在做一个使用React的项目,我对React是个新手,没有特别的经验在Symfony中设置webpack配置文件。浏览器中出现以下错误: