I wanted to make my own app in angular 4 without angular-cli and I encountered this problem:
Module not found: Error: Can't resolve './app/app.module'
I know that app.module.ts, app.component.ts, app.component.html are correct. So no worry there. Every import to file in same folder starts with ./
My file tree:
app.ts:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
webpack.config.js:
const path = require("path");
const webpack = require("webpack");
//const pathConfig = require("./pathconfig.json");
var ProgressBarPlugin = require("progress-bar-webpack-plugin");
var CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
context: path.resolve('./'),
plugins: [
new ProgressBarPlugin(),
new CopyWebpackPlugin([
{ from: "img/", to: "img/" },
{ from: "font/", to: "font/" },
])
],
module: {
rules: [
{
test: /\.(sass|scss)$/,
use: [
"style-loader",{
loader: "css-loader",
options: {
url: false
}
},
"sass-loader",
]
},
{
test: /\.(ts)$/,
use: [
"babel-loader",
"ts-loader"
]
}
]
},
entry: {
app: "./ts/app.ts"
},
output: {
path: path.resolve('./../public_html'),
filename: "js/[name].bundle.js",
},
};
tsconfig.json
{
"compilerOptions": {
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"/node_modules/@types"
],
"lib" : [
"es2016",
"dom"
]
}
}
Am I missing something or what?