Closed JoelYourstone closed 8 years ago
Webpack require()-syntax is not supported by the piping package. The next version of the starterkit will not depend on piping anymore.
Related to #41
webpack isomorphic tools may be helpful in solving this problem, as it allows you to require() css files and other assets on the server the same way you would in webpack built client side code. I also mentioned this in #41
Any news on this? I'm having the same problem with scss file.
[1] [piping] can't execute file: /Users/rparent/Documents/CTSProjects/isomorphic-boiler-plate/babel.server.js
[1] [piping] error given was: SyntaxError: /Users/rparent/Documents/CTSProjects/isomorphic-boiler-plate/style/scss/test.scss: Unexpected token (1:0)
[1] > 1 | .container
[1] | ^
[1] 2 | {
[1] 3 | background-color: red;
[1] 4 | }
And here is my webpack file
var webpack = require("webpack");
var path = require("path");
module.exports = {
target: "web",
cache: false,
context: __dirname,
devtool: false,
entry: ["./src/config/client"],
output: {
path: path.join(__dirname, "build/dist"),
filename: "client.js",
chunkFilename: "[name].[id].js",
publicPath: "dist/"
},
plugins: [
new webpack.DefinePlugin({__CLIENT__: true, __SERVER__: false}),
new webpack.DefinePlugin({"process.env": {NODE_ENV: '"production"'}}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin()
],
module: {
loaders: [
{test: /\.json$/, loaders: ["json-loader"]},
{test: /\.scss$/, loaders: ["style", "css", "sass"]},
{test: /\.js$/, loaders: ["babel-loader?stage=0&optional=runtime&plugins=typecheck"], exclude: /node_modules/}
]
},
resolve: {
modulesDirectories: [
"src",
"node_modules",
"web_modules",
"style"
],
extensions: ["", ".json", ".js", ".scss"]
},
node: {
__dirname: true,
fs: "empty",
net: "empty",
tls: "empty"
}
};
I am having exactly the same problem. Haven't found any solution so far.
I managed to use webpack-isomorphic-tools and pipe my scss files into my components. That was like 2 months ago so it might not be relevant anymore.
Right, I did that yesterday night and it looks like webpack-isomorphic-tools
is the only solution.
It took a while but the server-side now uses Webpack too. That means many webpack loaders should work on the server as well including url-loader
and css-loader
. (Piping is also gone, the server gets instant code updates from Webpack HMR!)
So please try release ^5.0.0.
Whenever I try to require a css or scss file (with appropriate loaders) I get errors when I run "npm run watch":
Dependencies in package.json
Main.js