NextJs with Tailwind, problem with removed unused styles on develope mode - docker

I've started project where in the front is Next.js. I've decide to create it with Tailwind. Below my package.json with versions and dependencies:
{
"name": "frontend",
"private": true,
"scripts": {
"dev": "next dev -p 3000",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"#emotion/react": "^11.7.0",
"#emotion/styled": "^11.6.0",
"#fontsource/roboto": "^4.5.1",
"#mui/icons-material": "^5.2.1",
"#mui/lab": "^5.0.0-alpha.59",
"#mui/material": "^5.2.3",
"#mui/x-data-grid": "^5.1.0",
"#reduxjs/toolkit": "^1.6.2",
"#twilio/voice-sdk": "^2.0.1",
"axios": "^0.24.0",
"formik": "^2.2.9",
"lodash": "^4.17.21",
"next": "12.0.5",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-query": "^3.34.5",
"react-redux": "^7.2.6",
"redux": "^4.1.2",
"sass": "^1.44.0",
"swr": "^1.1.0",
"yup": "^0.32.11"
},
"devDependencies": {
"#fullhuman/postcss-purgecss": "^4.1.3",
"#types/node": "16.11.11",
"#types/react": "17.0.37",
"autoprefixer": "^10.4.2",
"eslint": "8.3.0",
"eslint-config-next": "12.0.5",
"postcss": "^8.4.5",
"postcss-preset-env": "^7.2.3",
"tailwindcss": "^3.0.15",
"typescript": "4.5.2"
}
}
I run this project locally at the moment, I use Docker for this, and this is my Dockerfile:
FROM node:alpine
ENV PORT 3000
RUN apk add --no-cache libc6-compat
WORKDIR /app
COPY package*.json /app/
COPY yarn.lock /app/
RUN yarn install --ignore-engines
COPY . /app
RUN yarn build
EXPOSE 3000
CMD ["node_modules/.bin/next", "dev"]
This is my tailwind.config.js:
module.exports = {
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
minWidth: {
'xs': '20rem',
'56': '14rem',
'24': '6rem'
},
minHeight: {
'50': '50vh',
'5': '5rem',
'1/6': '16.666667%',
'5/6': '83.333333%',
'screen': '100vh',
'85v': '85vh'
},
backgroundColor: theme => ({
...theme('colors'),
'dark': '#343a40',
'strong-dark': '#212529',
'normal': '#ecedee'
}),
extend: {
width: {
'49/50': '98%',
'max-full': '500vw'
},
height: {
'max-full': '500vh'
},
spacing: {
'13': '13.4rem',
'14.4': '14.4rem',
'6.4': '6.4rem',
'15v': '15vh'
}
},
},
plugins: [],
}
I have problem with tailwind styles. From unknown reason styles are changing in files inside components due developing, but not inside pages directory. Due building every styles inside pages directory are loaded, but after changing/adding something classes are not recognized. If I change something inside tailwind.config.js classes are loading in every file, but still after that if I change/add some class that is not used before anywhere next is not recognizing it. I've looked for spelling bugs, I try reload node_modules, but still going back to the same point.
Anyone has the same problem?

Related

How to add a unique constraint on type field with Graphql and Neo4j?

I'm making a GRANDStack application so I'm using neo4j and graphql,
I have this type in my schema.graphql file :
type User {
userId: ID!
username: String! #unique
mail: String! #unique
password: String! #private
}
But I'm still able to create multiple accounts with the same
I know this is possible when I look at neo4j documentation here :
https://neo4j.com/docs/graphql-manual/current/directives/#_unique
but the only I found for now is to manually do something like this in my database :
CREATE CONSTRAINT ON (u:User) ASSERT u.mail IS UNIQUE;
But it's not a good idea, I want this to be automatic
I think my package.json is also up to date :
{
"name": "grand-stack-starter-api",
"version": "0.0.1",
"description": "API app for GRANDstack",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start:dev": "./node_modules/.bin/nodemon --watch src --ext js,graphql --exec babel-node src/index.js",
"build": "babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build",
"now-build": "babel src --out-dir build && shx cp src/schema.graphql build",
"start": "npm run build && node build/index.js",
"seedDb": "./node_modules/.bin/babel-node src/seed/seed-db.js"
},
"author": "William Lyon",
"license": "MIT",
"dependencies": {
"#apollo/client": "^3.2.5",
"#neo4j/graphql": "^2.4.0",
"apollo-server": "^3.5.0",
"apollo-server-lambda": "^2.19.0",
"csv-parse": "^4.10.1",
"dotenv": "^7.0.0",
"graphql": "^16.0.1",
"neo4j-driver": "^4.4.0",
"node-fetch": "^2.6.0",
"react": "^16.13.1"
},
"devDependencies": {
"#babel/cli": "^7.8.4",
"#babel/core": "^7.9.0",
"#babel/node": "^7.8.7",
"#babel/plugin-proposal-class-properties": "^7.8.3",
"#babel/plugin-transform-runtime": "^7.9.0",
"#babel/preset-env": "^7.9.0",
"#babel/preset-react": "^7.9.4",
"#babel/preset-typescript": "^7.9.0",
"#babel/runtime-corejs3": "^7.9.2",
"babel-plugin-auto-import": "^1.0.5",
"babel-plugin-module-resolver": "^4.0.0",
"cross-env": "^7.0.2",
"nodemon": "^1.19.1",
"shx": "^0.3.2"
}
}
So, turned out the documentation is not updated
To fix this I first had to follow this :
https://neo4j.com/docs/graphql-manual/current/type-definitions/constraints/#type-definitions-constraints-unique
the solution would be to add this which is wrong
await neoSchema.assertConstraints({ options: { create: true }});
I talked with someone working at neo4j in their discord and the right function one :
await neoSchema.assertIndexesAndConstraints({ options: { create: true }});
If like me you can't do await since your code is not in a function you can do something like this with .then :
const neoSchema = new Neo4jGraphQL({
...
})
neoSchema
.assertIndexesAndConstraints({ options: { create: true } })
.then(() => {
const server = new ApolloServer({
...
app.listen({ host, port, path }, () => {
console.log(`GraphQL server ready at http://${host}:${port}${path}`)
})
})

Compiling js via webpacker results in: SassError: expected "{"

I'm trying to use scss in my rails application, configured by webpacker. Whenever I run rails webpacker:compile, I get the following error:
ERROR in ./app/javascript/stylesheets/application.scss
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
SassError: expected "{".
╷
1 │ import api from "!../../../node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js";
│ ^
╵
app/javascript/stylesheets/application.scss 1:95 root stylesheet
I'm having trouble debugging this problem and would appreciate any help.
Dependencies
rails: 6.1
webpacker: 6.0.0.pre1
#webpack-cli/serve
webpack: 5.11
webpack-cli: 4.2
webpack-dev-server: 3.11
package.json
{
"name": "ostor",
"private": true,
"dependencies": {
"#popperjs/core": "^2.6.0",
"#rails/actioncable": "^6.1.2-1",
"#rails/activestorage": "^6.1.2-1",
"#rails/ujs": "^6.1.2-1",
"#rails/webpacker": "^6.0.0-beta.5",
"autoprefixer": "^10.2.4",
"bootstrap": "^v5.0.0-beta2",
"css-loader": "^5.0.2",
"css-minimizer-webpack-plugin": "^1.2.0",
"d3": "^6.2.0",
"jquery": "^3.5.1",
"mini-css-extract-plugin": "^1.3.7",
"postcss": "^8.2.6",
"postcss-loader": "^5.0.0",
"sass": "^1.32.7",
"sass-loader": "^11.0.1",
"style-loader": "^2.0.0",
"turbolinks": "^5.2.0",
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0"
},
"version": "0.1.0",
"devDependencies": {
"#webpack-cli/serve": "^1.3.0",
"webpack-dev-server": "^3.11.2"
},
"babel": {
"presets": [
"./node_modules/#rails/webpacker/package/babel/preset.js"
]
},
"browserslist": [
"defaults"
]
}
config/webpack/base.js:
const { webpackConfig, merge } = require('#rails/webpacker')
const customConfig = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
exclude: /node_modules/,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
],
},
}
module.exports = merge(webpackConfig, customConfig)
app/javascript/packs/application.js
import ActiveStorage from "#rails/activestorage";
import * as RailsUjs from "#rails/ujs";
import Turbolinks from "turbolinks";
ActiveStorage.start();
RailsUjs.start();
Turbolinks.start();
import "channels";
import "bootstrap";
import "../stylesheets/application.scss";
Remove the custom config rules you added for SASS/SCSS. Webpacker 6 will provide the appropriate CSS rules for you when it detects you've installed css-loader, postcss-loader, mini-css-extract-plugin, etc.
For the shakapacker users:
You don't need to add the option:
test: /\.s[ac]ss$/i
in the "rules" section. You just need to add:
yarn add sass sass-loader
and:
extensions:
- .sass
- .scss
in your webpacker.yml file, and shakapacker will transpile sass/scss files.

Vue deployment with Dokku

My project is working and build correctly in local, in development or production, but when I try to push to my DigitalOcean Ubuntu server through Dokku it crashes
# server.js at the root
const express = require('express');
const path = require('path');
const serveStatic = require('serve-static');
let app = express();
app.use(serveStatic(__dirname + "/dist"));
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log('Listening on port ' + port)
});
# current vue.config.js
# note that it had no option originally but changing it didn't solve the problem
const path = require('path')
module.exports = {
publicPath: '/',
configureWebpack: {
resolve: {
alias: {
'#': path.resolve(__dirname, 'src/')
}
}
},
css: {
loaderOptions: {
sass: {
data: `#import "src/assets/styles/helpers.scss";`
}
}
},
pluginOptions: {}
}
And here's the crash
- Building for production...
ERROR Failed to compile with 24 errors2:31:56 PM
These dependencies were not found:
* #/components/Errors/DefaultError in ./src/main.js
* #/components/Layouts/ChatLayout in ./src/main.js
* #/components/Layouts/DashboardLayout in ./src/main.js
* #/components/Layouts/DefaultLayout in ./src/main.js
* #/mixins/CurrentIdentityMixin in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/ConnectRouting.vue?vue&type=script&lang=js&, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Chat/Events/File.vue?vue&type=script&lang=js& and 16 others
* #/mixins/LayoutMixin in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&, ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/ConnectRouting.vue?vue&type=script&lang=js&
This is very strange, it's as # wasn't recognised as shortcut in Vue, but I don't really know how to fix it. I think setting everything with relative path manually would solve the issue (it worked at least for the layouts when I tried); it's not really a fix though, just a bad workaround.
I also changed a few times the node / npm version, without success. Here's the package.json
{
"name": "askalfred-app",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"generate": "graphql-codegen",
"postinstall": "npm run build",
"start": "node server.js"
},
"dependencies": {
"#sentry/browser": "^5.4.0",
"#sentry/integrations": "^5.4.0",
"actioncable": "^5.2.2-1",
"apollo-boost": "^0.1.20",
"apollo-cache-inmemory": "^1.3.5",
"apollo-client": "^2.4.2",
"apollo-link": "^1.2.3",
"apollo-link-http": "^1.5.5",
"apollo-upload-client": "^10.0.1",
"autosize": "^4.0.2",
"epic-spinners": "^1.1.0",
"flexboxgrid": "^6.3.1",
"graphql": "^14.1",
"graphql-ruby-client": "^1.6.3",
"lowdb": "^1.0.0",
"mkdirp": "^0.5.1",
"moment": "^2.24.0",
"shortid": "^2.2.8",
"showdown": "^1.9.0",
"tingle.js": "^0.14.0",
"typescript": "^3.4.5",
"v-mask": "^1.3.3",
"vue": "^2.6.10",
"vue-analytics": "^5.17.0",
"vue-apollo": "3.0.0-beta.25",
"vue-notification": "^1.3.16",
"vue-router": "^3.0.1",
"vuelidate": "^0.7.4",
"vuex": "^3.0.1"
},
"devDependencies": {
"#graphql-codegen/cli": "^1.2.0",
"#graphql-codegen/fragment-matcher": "^1.2.0",
"#graphql-codegen/typescript": "^1.2.0",
"#vue/cli-plugin-babel": "^3.4.0",
"#vue/cli-plugin-eslint": "^3.5.1",
"#vue/cli-service": "^3.4.0",
"eslint": "^5.15.3",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0",
"eslint-plugin-vue": "^5.2.2",
"express": "^4.17.1",
"graphql-tag": "^2.9.0",
"node-sass": "^4.11.0",
"sass-loader": "^7.1.0",
"serve-static": "^1.14.1",
"vue-cli-plugin-apollo": "^0.20.0",
"vue-template-compiler": "^2.5.21"
},
"engines": {
"node": "v11.11.0",
"npm": "6.7.0"
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Any idea what I could be doing wrong?
Somewhat working solution
For anyone which would end up in the same situation, I believe most tutorial about Dokku / VueJS are out of date, and lead to stupid mistakes, or at the very least does not tackle the deployment correctly with the newer versions. After several hours I figured:
"postinstall": "npm run build",
I removed this from the package.json and now it deploys without problem. I'm unsure if the success was due to removing the /dist from .gitignore in my project and building it locally, or if the something happens while it's deployed, but it's enough in my case.
Better way imo.
Just create an empty file called exactly ".static" on the root folder of the project.
Then on the dokku server run:
dokku config:set yourappname NGINX_ROOT=dist BUILDPACK_URL=https://github.com/dokku/buildpack-nginx
The dist folder needs to be commited (remove it from .gitignore).
Then run "git push dokku master".

white screen displayed after splashscreen in nativescript ios

There is white screen displaying after splash screen for few seconds in nativescript ios. It has been happening only for our project but sample project is working fine. I checked both simulator and iPhone 5, iPhone 6 , iPad mini ,white screen is displaying in all devices. I am using Nativescript with Angular 4, Here I included my package.json
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "com.preludesys.calladoc",
"tns-ios": {
"version": "3.1.0"
}
},
"scripts": {
"tslint": "tslint -p tsconfig.json",
"ns-bundle": "ns-bundle",
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
"start-android-bundle": "npm run ns-bundle --android --run-app",
"start-ios-bundle": "npm run ns-bundle --ios --run-app",
"build-android-bundle": "npm run ns-bundle --android --build-app",
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
},
"dependencies": {
"#angular/animations": "~4.1.0",
"#angular/common": "~4.1.0",
"#angular/compiler": "~4.1.0",
"#angular/core": "~4.1.0",
"#angular/forms": "~4.1.0",
"#angular/http": "~4.1.0",
"#angular/platform-browser": "~4.1.0",
"#angular/router": "~4.1.0",
"nativescript": "^3.2.0",
"nativescript-angular": "~3.0.0",
"nativescript-camera": "^3.0.1",
"nativescript-drop-down": "^3.1.0",
"nativescript-google-maps-sdk": "^2.3.2",
"nativescript-imagepicker": "^3.0.6",
"nativescript-iqkeyboardmanager": "^1.1.0",
"nativescript-loading-indicator": "^2.3.2",
"nativescript-phone": "^1.3.1",
"nativescript-ripple": "^2.0.0",
"nativescript-telerik-ui": "^3.0.4",
"nativescript-theme-core": "~1.0.2",
"nativescript-unit-test-runner": "^0.3.4",
"nativescript-xml2js": "^0.5.2",
"reflect-metadata": "~0.1.8",
"rxjs": "~5.3.0",
"tns-core-modules": "^3.1.1",
"zone.js": "~0.8.2"
},
"devDependencies": {
"#angular/compiler-cli": "~4.1.0",
"#ngtools/webpack": "^1.3.0",
"babel-traverse": "6.24.1",
"babel-types": "6.24.1",
"babylon": "6.17.1",
"codelyzer": "^3.0.1",
"copy-webpack-plugin": "~4.0.1",
"extract-text-webpack-plugin": "~2.1.0",
"filewalker": "^0.1.3",
"jasmine-core": "^2.6.2",
"karma": "^1.7.0",
"karma-jasmine": "^1.0.2",
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-typescript": "~0.4.0",
"nativescript-dev-webpack": "next",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.0.2",
"tslint": "^5.4.2",
"typescript": "~2.2.1",
"webpack": "~2.6.1",
"webpack-bundle-analyzer": "^2.8.2",
"webpack-sources": "~1.0.1",
"nativescript-worker-loader": "~0.8.1"
}
}
i dont know what is the issue and how can i fix it. so please j=help me.
You should repeat the layout of your boot screen or a slightly different version of it (with a spinner and loading... message) hard coded that gets removed or drawn over once the app is actually loaded. This will give a smooth and professional looking transition between the boot screen and the loaded application.
This short "splash after the splashscreen" appears on iOS during the load of the initial page.
You cannot avoid it. However, you can change the color in your global CSS file with this code:
Page {
background-color: black;
}
In our apps this white screen becomes more prominent after adding a few "heavy" plugins, as nativescript-telerik-ui, nativescript-google-maps-sdk, etc.
It happens on old (slow) Android devices, too.
It seems it is unavoidable, which is a shame, really. One thing you could try is to optimize the loading time with Webpack, lazy loading, etc., so the app loads faster.
It also is recommended to change the Page background color programmatically on boot.
I am using frames and i found solution to make Frame background same as Splash screen
Frame {
background:#4285F4;
}
For this to work on Android {N}7 too, do:
frame.ns-root {
background-color: black;
}

templateUrl in Angular2 Component not loading URL

this is my Component
import { Component, OnInit } from '#angular/core';
#Component({
selector: 'homeView',
templateUrl: '/home/home'
})
export class HomeViewComponent implements OnInit {
ngOnInit(): void {}
}
I am using AngularJS 2 with TypeScript 1.8.5 and trying to create component that will load template from Controller Action.
I am getting this error
main.bundle.js:667 Uncaught Error: Cannot find module ".//home/home"
I also tried it with home/home, the error is almost the same
main.bundle.js:667 Uncaught Error: Cannot find module "./home/home"
Error is not compile time error however - it pops up in browser console when page and the component is being loaded
So as you can see i dont want to load static template like home.template.html - that is working correctly. I want to load an HTML template from asp.net MVC Controller Action. I am not even hitting the debug point in the HomeController Home action.
Is there any way to make this work ? Seems like Angular keeps inserting this './' sign. Is there a way to configure this ? I ve read several tutorials on angular2 + mvc and it seems that this should be possible, but for some reason its not working for me.
My app.routes.ts
import {Routes} from "#angular/router";
import {MainViewComponent} from "../views/main-view/main-view.component";
import {MinorViewComponent} from "../views/minor-view/minor-view.component";
import {HomeViewComponent} from "../views/home-view/home-view.component";
export const ROUTES:Routes = [
// Main redirect
{ path: '', redirectTo: 'mainView', pathMatch: 'full'},
// App views
{path: 'mainView', component: MainViewComponent},
{path: 'minorView', component: MinorViewComponent},
{path: 'homeView', component: HomeViewComponent}
// Handle all other routes
//{path: '**', component: MainViewComponent }
];
app.module.ts
#NgModule({
declarations: [AppComponent],
imports : [
// Angular modules
BrowserModule,
HttpModule,
// Views
MainViewModule,
MinorViewModule,
// Modules
NavigationModule,
FooterModule,
TopnavbarModule,
RouterModule.forRoot(Approutes.ROUTES)
],
providers : [{provide: LocationStrategy, useClass: HashLocationStrategy}],
bootstrap : [AppComponent]
})
export class AppModule {}
EDIT : Some more info :
packages.json
{
"name": "inspinia_angular2_starter",
"version": "1.0.0",
"description": "Inspinia Admin Theme",
"repository": "https://wrapbootstrap.com/theme/inspinia-responsive-admin-theme-WB0R5L90S",
"scripts": {
"typings-install": "typings install",
"postinstall": "npm run typings-install",
"build": "webpack --inline --colors --progress --display-error-details --display-cached",
"server": "webpack-dev-server --inline --colors --progress --display-error-details --display-cached --port 3000 --content-base src",
"start": "npm run server"
},
"dependencies": {
"#angular/common": "2.0.0",
"#angular/compiler": "2.0.0",
"#angular/core": "2.0.0",
"#angular/forms": "2.0.0",
"#angular/http": "2.0.0",
"#angular/platform-browser": "2.0.0",
"#angular/platform-browser-dynamic": "2.0.0",
"#angular/router": "3.0.0",
"#angular/upgrade": "2.0.0",
"angular2-in-memory-web-api": "0.0.20",
"animate.css": "3.1.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.6.1",
"ie-shim": "^0.1.0",
"jquery": "^3.1.0",
"metismenu": "^2.5.0",
"pace": "0.0.4",
"pace-progress": "^1.0.2",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.27",
"typings": "^1.3.2",
"zone.js": "^0.6.23"
},
"devDependencies": {
"angular2-template-loader": "^0.4.0",
"awesome-typescript-loader": "^1.1.1",
"bootstrap-webpack": "0.0.5",
"css-loader": "^0.23.1",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"imports-loader": "^0.6.5",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.4",
"typescript": "~1.8.5",
"url-loader": "^0.5.7",
"webpack": "^1.12.9",
"webpack-dev-server": "^1.14.0",
"webpack-merge": "^0.8.4"
}
}
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"bower_components"
],
"awesomeTypescriptLoaderOptions": {
"useWebpackText": true
},
"compileOnSave": false,
"buildOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}
App is built using webpack
main.browser.ts
import {platformBrowserDynamic} from "#angular/platform-browser-dynamic";
import {AppModule} from "../src/app/app.module";
/*
* Bootstrap Angular app with a top level NgModule
*/
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.error(err));
So, after what seemed like an eternity I finally got the the bottom of this.
The problem was in webpack using angular2-template-loader.
This module is responsible for inlining html template. In other words, it will do a require (using your templateUrl) behind the scenes on the template tag of your component. This, of course, breaks the functionality if you are using actual URLs as templateUrl and not PATHs, therefore the template is not there.
Based on what i read, it seems like the authors wont support this in the future. (If template is not found -> try to load it from URL)
More info here - https://github.com/angular/angular-cli/issues/1605
So, basically I just removed this component from config file :
webpack.config.js
BEFORE
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader', 'angular2-template-loader']
},
{
test: /\.css$/,
loader:
AFTER
module: {
loaders: [
{
test: /\.ts$/,
loaders: ['awesome-typescript-loader']
},
{
test: /\.css$/,
loader:

Resources