Angular - trying import angular template shows 404 error
up vote
0
down vote
favorite
i searched the whole SO for any solution for this problem, every answer is the same: check if relative path to your template is correct. my problem is, i'm testing all possible paths, in different folders and that's no matter, in all folders my template is not being located, returning a 404 error.
Console Tab
Network tab
my webpack.config.js
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports =
mode: 'development',
watch: true,
devtool: 'source-map',
entry: './src/index.js',
output:
path: path.resolve(__dirname, 'dist'),
filename: 'app.js'
,
module:
rules: [
test: /.css$/,
use: [
loader: MiniCssExtractPlugin.loader,
options:
publicPath: './dist'
,
"css-loader"
]
,
test: /.scss$/,
use: [
loader: "style-loader",
loader: "css-loader",
loader: "sass-loader"
]
,
test: /.(html)$/,
use: [
loader:'raw-loader'
]
]
,
stats:
errorDetails: true,
errors: true
,
devServer:
contentBase: './dist',
compress: true,
port: 9000,
publicPath: '/',
watchContentBase: true,
hot: true,
inline: true
,
plugins: [
new MiniCssExtractPlugin(
filename: "app.css",
chunkFilename: "[id].css"
),
new HtmlWebpackPlugin(
template: './index.html'
),
new webpack.HotModuleReplacementPlugin()
]
;
my index.js
import angular from 'angular'
import uirouter from '@uirouter/angularjs'
//import uirouterStateHelper from 'angular-ui-router.statehelper'
import 'bootstrap/dist/css/bootstrap.min.css'
angular.module('petApp', [uirouter])
.config(function($stateProvider, $urlRouterProvider)
// For any unmatched url, send to /
$urlRouterProvider.otherwise('/home')
var homeState =
name: 'home',
url: '/home',
templateUrl: './test.html',
controller: 'HomeController'
$stateProvider.state(homeState);
).controller('HomeController', HomeController)
function HomeController ($scope, $http)
console.log($scope);
angularjs webpack angular-ui-router
add a comment |
up vote
0
down vote
favorite
i searched the whole SO for any solution for this problem, every answer is the same: check if relative path to your template is correct. my problem is, i'm testing all possible paths, in different folders and that's no matter, in all folders my template is not being located, returning a 404 error.
Console Tab
Network tab
my webpack.config.js
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports =
mode: 'development',
watch: true,
devtool: 'source-map',
entry: './src/index.js',
output:
path: path.resolve(__dirname, 'dist'),
filename: 'app.js'
,
module:
rules: [
test: /.css$/,
use: [
loader: MiniCssExtractPlugin.loader,
options:
publicPath: './dist'
,
"css-loader"
]
,
test: /.scss$/,
use: [
loader: "style-loader",
loader: "css-loader",
loader: "sass-loader"
]
,
test: /.(html)$/,
use: [
loader:'raw-loader'
]
]
,
stats:
errorDetails: true,
errors: true
,
devServer:
contentBase: './dist',
compress: true,
port: 9000,
publicPath: '/',
watchContentBase: true,
hot: true,
inline: true
,
plugins: [
new MiniCssExtractPlugin(
filename: "app.css",
chunkFilename: "[id].css"
),
new HtmlWebpackPlugin(
template: './index.html'
),
new webpack.HotModuleReplacementPlugin()
]
;
my index.js
import angular from 'angular'
import uirouter from '@uirouter/angularjs'
//import uirouterStateHelper from 'angular-ui-router.statehelper'
import 'bootstrap/dist/css/bootstrap.min.css'
angular.module('petApp', [uirouter])
.config(function($stateProvider, $urlRouterProvider)
// For any unmatched url, send to /
$urlRouterProvider.otherwise('/home')
var homeState =
name: 'home',
url: '/home',
templateUrl: './test.html',
controller: 'HomeController'
$stateProvider.state(homeState);
).controller('HomeController', HomeController)
function HomeController ($scope, $http)
console.log($scope);
angularjs webpack angular-ui-router
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
1
i'm not familar with webpack , you can google to find out. It's should bewebpack copy src to dist
or something smilar. Or try to placeoptions: publicPath: './dist'
after test.html loader config before using google :)
– Zuko
Nov 10 at 19:55
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i searched the whole SO for any solution for this problem, every answer is the same: check if relative path to your template is correct. my problem is, i'm testing all possible paths, in different folders and that's no matter, in all folders my template is not being located, returning a 404 error.
Console Tab
Network tab
my webpack.config.js
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports =
mode: 'development',
watch: true,
devtool: 'source-map',
entry: './src/index.js',
output:
path: path.resolve(__dirname, 'dist'),
filename: 'app.js'
,
module:
rules: [
test: /.css$/,
use: [
loader: MiniCssExtractPlugin.loader,
options:
publicPath: './dist'
,
"css-loader"
]
,
test: /.scss$/,
use: [
loader: "style-loader",
loader: "css-loader",
loader: "sass-loader"
]
,
test: /.(html)$/,
use: [
loader:'raw-loader'
]
]
,
stats:
errorDetails: true,
errors: true
,
devServer:
contentBase: './dist',
compress: true,
port: 9000,
publicPath: '/',
watchContentBase: true,
hot: true,
inline: true
,
plugins: [
new MiniCssExtractPlugin(
filename: "app.css",
chunkFilename: "[id].css"
),
new HtmlWebpackPlugin(
template: './index.html'
),
new webpack.HotModuleReplacementPlugin()
]
;
my index.js
import angular from 'angular'
import uirouter from '@uirouter/angularjs'
//import uirouterStateHelper from 'angular-ui-router.statehelper'
import 'bootstrap/dist/css/bootstrap.min.css'
angular.module('petApp', [uirouter])
.config(function($stateProvider, $urlRouterProvider)
// For any unmatched url, send to /
$urlRouterProvider.otherwise('/home')
var homeState =
name: 'home',
url: '/home',
templateUrl: './test.html',
controller: 'HomeController'
$stateProvider.state(homeState);
).controller('HomeController', HomeController)
function HomeController ($scope, $http)
console.log($scope);
angularjs webpack angular-ui-router
i searched the whole SO for any solution for this problem, every answer is the same: check if relative path to your template is correct. my problem is, i'm testing all possible paths, in different folders and that's no matter, in all folders my template is not being located, returning a 404 error.
Console Tab
Network tab
my webpack.config.js
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports =
mode: 'development',
watch: true,
devtool: 'source-map',
entry: './src/index.js',
output:
path: path.resolve(__dirname, 'dist'),
filename: 'app.js'
,
module:
rules: [
test: /.css$/,
use: [
loader: MiniCssExtractPlugin.loader,
options:
publicPath: './dist'
,
"css-loader"
]
,
test: /.scss$/,
use: [
loader: "style-loader",
loader: "css-loader",
loader: "sass-loader"
]
,
test: /.(html)$/,
use: [
loader:'raw-loader'
]
]
,
stats:
errorDetails: true,
errors: true
,
devServer:
contentBase: './dist',
compress: true,
port: 9000,
publicPath: '/',
watchContentBase: true,
hot: true,
inline: true
,
plugins: [
new MiniCssExtractPlugin(
filename: "app.css",
chunkFilename: "[id].css"
),
new HtmlWebpackPlugin(
template: './index.html'
),
new webpack.HotModuleReplacementPlugin()
]
;
my index.js
import angular from 'angular'
import uirouter from '@uirouter/angularjs'
//import uirouterStateHelper from 'angular-ui-router.statehelper'
import 'bootstrap/dist/css/bootstrap.min.css'
angular.module('petApp', [uirouter])
.config(function($stateProvider, $urlRouterProvider)
// For any unmatched url, send to /
$urlRouterProvider.otherwise('/home')
var homeState =
name: 'home',
url: '/home',
templateUrl: './test.html',
controller: 'HomeController'
$stateProvider.state(homeState);
).controller('HomeController', HomeController)
function HomeController ($scope, $http)
console.log($scope);
angularjs webpack angular-ui-router
angularjs webpack angular-ui-router
asked Nov 10 at 19:34
Leandro RR
251316
251316
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
1
i'm not familar with webpack , you can google to find out. It's should bewebpack copy src to dist
or something smilar. Or try to placeoptions: publicPath: './dist'
after test.html loader config before using google :)
– Zuko
Nov 10 at 19:55
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02
add a comment |
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
1
i'm not familar with webpack , you can google to find out. It's should bewebpack copy src to dist
or something smilar. Or try to placeoptions: publicPath: './dist'
after test.html loader config before using google :)
– Zuko
Nov 10 at 19:55
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
1
1
i'm not familar with webpack , you can google to find out. It's should be
webpack copy src to dist
or something smilar. Or try to place options: publicPath: './dist'
after test.html loader config before using google :)– Zuko
Nov 10 at 19:55
i'm not familar with webpack , you can google to find out. It's should be
webpack copy src to dist
or something smilar. Or try to place options: publicPath: './dist'
after test.html loader config before using google :)– Zuko
Nov 10 at 19:55
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
my solution was make webpack copy my templates from src/templates/
folder to my ./dist
folder using the Copy Webpack Plugin https://github.com/webpack-contrib/copy-webpack-plugin
my strugle was, when running the development server it should (or not) copy the files at run time to dist, but i used the build
command (after set the plugin) to copy the files and now is working fine.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
my solution was make webpack copy my templates from src/templates/
folder to my ./dist
folder using the Copy Webpack Plugin https://github.com/webpack-contrib/copy-webpack-plugin
my strugle was, when running the development server it should (or not) copy the files at run time to dist, but i used the build
command (after set the plugin) to copy the files and now is working fine.
add a comment |
up vote
0
down vote
my solution was make webpack copy my templates from src/templates/
folder to my ./dist
folder using the Copy Webpack Plugin https://github.com/webpack-contrib/copy-webpack-plugin
my strugle was, when running the development server it should (or not) copy the files at run time to dist, but i used the build
command (after set the plugin) to copy the files and now is working fine.
add a comment |
up vote
0
down vote
up vote
0
down vote
my solution was make webpack copy my templates from src/templates/
folder to my ./dist
folder using the Copy Webpack Plugin https://github.com/webpack-contrib/copy-webpack-plugin
my strugle was, when running the development server it should (or not) copy the files at run time to dist, but i used the build
command (after set the plugin) to copy the files and now is working fine.
my solution was make webpack copy my templates from src/templates/
folder to my ./dist
folder using the Copy Webpack Plugin https://github.com/webpack-contrib/copy-webpack-plugin
my strugle was, when running the development server it should (or not) copy the files at run time to dist, but i used the build
command (after set the plugin) to copy the files and now is working fine.
answered Nov 10 at 20:25
Leandro RR
251316
251316
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242688%2fangular-trying-import-angular-template-shows-404-error%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
try copy test.html to your dist folder , if working fine then check the webpack config rules
– Zuko
Nov 10 at 19:37
copied and worked... but my templates are stored under src/templates, what to do?
– Leandro RR
Nov 10 at 19:50
1
i'm not familar with webpack , you can google to find out. It's should be
webpack copy src to dist
or something smilar. Or try to placeoptions: publicPath: './dist'
after test.html loader config before using google :)– Zuko
Nov 10 at 19:55
OK,i will check it out and post my answer here
– Leandro RR
Nov 10 at 20:02