webpack does not include css file
I have build a react-stepper and uploaded it to github.
When i want to build my App, webpack does not include font-awesome css. But it includes my own style.scss file. I use the style loader in webpack.
In dev mode everything works fine. Only in build mode it does not work.
Here is my repo:
https://github.com/tkwant/react-stepper-wizard
Here is my webpack.build.config file:
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /.(scss|css)$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader"
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "react-stepper-wizard.js",
library: "Stepper",
libraryTarget: "umd"
},
externals: ["react", "react-dom", "font-awesome"],
plugins: [
new CleanWebpackPlugin(["dist"]),
new webpack.HotModuleReplacementPlugin()
],
devtool: "source-map",
devServer: {
contentBase: "./examples",
hot: true,
port: 9001
}
};
It would be fine if somebody can help me here or can do a PR to fix this problem.
javascript css reactjs webpack
add a comment |
I have build a react-stepper and uploaded it to github.
When i want to build my App, webpack does not include font-awesome css. But it includes my own style.scss file. I use the style loader in webpack.
In dev mode everything works fine. Only in build mode it does not work.
Here is my repo:
https://github.com/tkwant/react-stepper-wizard
Here is my webpack.build.config file:
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /.(scss|css)$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader"
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "react-stepper-wizard.js",
library: "Stepper",
libraryTarget: "umd"
},
externals: ["react", "react-dom", "font-awesome"],
plugins: [
new CleanWebpackPlugin(["dist"]),
new webpack.HotModuleReplacementPlugin()
],
devtool: "source-map",
devServer: {
contentBase: "./examples",
hot: true,
port: 9001
}
};
It would be fine if somebody can help me here or can do a PR to fix this problem.
javascript css reactjs webpack
1
It should not be in theexternals
. That is for excluding modules from the package.
– Gabriele Petrioli
Jan 20 at 13:42
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45
add a comment |
I have build a react-stepper and uploaded it to github.
When i want to build my App, webpack does not include font-awesome css. But it includes my own style.scss file. I use the style loader in webpack.
In dev mode everything works fine. Only in build mode it does not work.
Here is my repo:
https://github.com/tkwant/react-stepper-wizard
Here is my webpack.build.config file:
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /.(scss|css)$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader"
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "react-stepper-wizard.js",
library: "Stepper",
libraryTarget: "umd"
},
externals: ["react", "react-dom", "font-awesome"],
plugins: [
new CleanWebpackPlugin(["dist"]),
new webpack.HotModuleReplacementPlugin()
],
devtool: "source-map",
devServer: {
contentBase: "./examples",
hot: true,
port: 9001
}
};
It would be fine if somebody can help me here or can do a PR to fix this problem.
javascript css reactjs webpack
I have build a react-stepper and uploaded it to github.
When i want to build my App, webpack does not include font-awesome css. But it includes my own style.scss file. I use the style loader in webpack.
In dev mode everything works fine. Only in build mode it does not work.
Here is my repo:
https://github.com/tkwant/react-stepper-wizard
Here is my webpack.build.config file:
const webpack = require("webpack");
const CleanWebpackPlugin = require("clean-webpack-plugin");
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /.(scss|css)$/,
use: [
{
loader: "style-loader" // creates style nodes from JS strings
},
{
loader: "css-loader" // translates CSS into CommonJS
},
{
loader: "sass-loader" // compiles Sass to CSS
}
]
},
{
test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/,
loader: "url-loader?limit=10000&mimetype=application/font-woff"
},
{
test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/,
loader: "file-loader"
}
]
},
resolve: {
extensions: ["*", ".js", ".jsx"]
},
output: {
path: __dirname + "/dist",
publicPath: "/",
filename: "react-stepper-wizard.js",
library: "Stepper",
libraryTarget: "umd"
},
externals: ["react", "react-dom", "font-awesome"],
plugins: [
new CleanWebpackPlugin(["dist"]),
new webpack.HotModuleReplacementPlugin()
],
devtool: "source-map",
devServer: {
contentBase: "./examples",
hot: true,
port: 9001
}
};
It would be fine if somebody can help me here or can do a PR to fix this problem.
javascript css reactjs webpack
javascript css reactjs webpack
asked Jan 20 at 12:18
Tobias KTobias K
19412
19412
1
It should not be in theexternals
. That is for excluding modules from the package.
– Gabriele Petrioli
Jan 20 at 13:42
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45
add a comment |
1
It should not be in theexternals
. That is for excluding modules from the package.
– Gabriele Petrioli
Jan 20 at 13:42
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45
1
1
It should not be in the
externals
. That is for excluding modules from the package.– Gabriele Petrioli
Jan 20 at 13:42
It should not be in the
externals
. That is for excluding modules from the package.– Gabriele Petrioli
Jan 20 at 13:42
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45
add a comment |
2 Answers
2
active
oldest
votes
You're copying a .css
file, right?
You may want to try the webpack-copy-plugin
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
TheREADME.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy
– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
add a comment |
solution was to use url loader.
{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f54276351%2fwebpack-does-not-include-css-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You're copying a .css
file, right?
You may want to try the webpack-copy-plugin
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
TheREADME.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy
– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
add a comment |
You're copying a .css
file, right?
You may want to try the webpack-copy-plugin
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
TheREADME.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy
– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
add a comment |
You're copying a .css
file, right?
You may want to try the webpack-copy-plugin
You're copying a .css
file, right?
You may want to try the webpack-copy-plugin
answered Jan 20 at 13:13
Knight YoshiKnight Yoshi
506921
506921
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
TheREADME.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy
– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
add a comment |
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
TheREADME.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy
– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
can you explain how to use it? I dont understand why my scss file is loaded but the css file not. I have imported it in stepper.js the same way
– Tobias K
Jan 20 at 13:46
The
README.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy– Knight Yoshi
Jan 20 at 13:51
The
README.md
file covers the use of it fairly extensively. You just load it in the Webpack plugins and follow the config for the files that you want to copy– Knight Yoshi
Jan 20 at 13:51
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
ok i will try it. But it is still a bit confusing why the scss file is loaded and the css not...
– Tobias K
Jan 20 at 13:54
add a comment |
solution was to use url loader.
{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
add a comment |
solution was to use url loader.
{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
add a comment |
solution was to use url loader.
{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
solution was to use url loader.
{ test: /.woff(2)?(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
{ test: /.(ttf|eot|svg)(?v=[0-9].[0-9].[0-9])?$/, loader: "url-loader" },
answered Jan 20 at 17:18
Tobias KTobias K
19412
19412
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f54276351%2fwebpack-does-not-include-css-file%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
1
It should not be in the
externals
. That is for excluding modules from the package.– Gabriele Petrioli
Jan 20 at 13:42
when I remove it from externals it doesnt work, too
– Tobias K
Jan 20 at 13:45