Be careful!
devDependencies are not installed by default when installing packages via npm --production
If you want to compile your assets on server (during deployment), you will probably need to work around this or keep all your compilation-related packages in dependencies instead.
{
"name": "my-razzle-app",
"version": "0.1.0",
"license": "MIT",
"scripts": {
"start": "razzle start",
"build": "razzle build",
"test": "razzle test --env=jsdom",
"start:prod": "NODE_ENV=production node build/server.js"
},
"dependencies": {
"razzle": "^0.7.1",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-router-dom": "^4.1.1"
},
"devDependencies": {
"autoprefixer": "^7.1.1",
"node-sass": "^4.5.3",
"postcss-flexbugs-fixes": "^3.0.0",
"resolve-url-loader": "^2.1.0",
"sass-loader": "^6.0.6"
}
}
var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'app.[hash].js'
},
devtool: 'eval',
module: {
rules: [
{ test: /\.jsx?$/, exclude: /node_modules/, use: [ 'babel-loader' ], },
{ test: /\.scss|css$/,
use: [
{ loader: 'style-loader', options: { sourceMap: true } },
{ loader: 'css-loader', options: { sourceMap: true } },
{ loader: 'postcss-loader', options: { sourceMap: true } },
'resolve-url-loader',
{
loader: 'sass-loader',
query: {
sourceMap: true,
includePaths: [ path.resolve(__dirname, './node_modules') ]
}
}
]
}
]
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ hash: false, template: 'html-loader!./src/index.html' }),
],
resolve: {
modules: [ path.resolve('./src'), 'node_modules' ]
}
};
entry: [
'webpack-dev-server/client?http://localhost:3000',
'webpack/hot/only-dev-server',
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'app.[hash].js'
},
devtool: 'eval',
module: {
rules: [
{ test: /\.jsx?$/, exclude: /node_modules/, use: [ 'babel-loader' ], },
{ test: /\.scss|css$/,
use: [
{ loader: 'style-loader', options: { sourceMap: true } },
{ loader: 'css-loader', options: { sourceMap: true } },
{ loader: 'postcss-loader', options: { sourceMap: true } },
'resolve-url-loader',
{
loader: 'sass-loader',
query: {
sourceMap: true,
includePaths: [ path.resolve(__dirname, './node_modules') ]
}
}
]
}
]
},
plugins: [
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({ hash: false, template: 'html-loader!./src/index.html' }),
],
resolve: {
modules: [ path.resolve('./src'), 'node_modules' ]
}