Answer the question
In order to leave comments, you need to log in
Webpack 2 Sass loader?
Good day! Can't save CSS file after loaders.
Base config
var path = require("path")
var webpack = require('webpack')
module.exports = {
context: __dirname,
entry: {
app: './app/app.js',
style: './sass/main.scss',
vendors: ['react'],
},
output: {
path: path.resolve('../static/bundles/local/'),
filename: '[name]-[hash].js',
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({name: 'vendors', filename: 'vendors.js'}),
], // add all common plugins here
module: {
rules: []
},
resolve: {
modules: ['node_modules', 'bower_components'],
extensions: ['.js', '.jsx']
},
}
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')
var ExtractTextPlugin = require("extract-text-webpack-plugin")
var autoprefixer = require("autoprefixer")
var config = require('./webpack.base.config.js')
var path = require('path')
config.devtool = "#eval-source-map"
config.entry.app = ['webpack-dev-server/client?http://localhost:3001', 'webpack/hot/only-dev-server', './app/app.js'];
config.output.publicPath = 'http://localhost:3001/assets/bundles/';
config.plugins = config.plugins.concat([
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new BundleTracker({ filename: '../static/bundles/webpack-stats.json' }),
new ExtractTextPlugin('../static/css/main.min.css', {
allChunks: true
})
])
config.devServer = {
publicPath: config.output.publicPath,
hot: true,
inline: true,
historyApiFallback: false,
stats: 'errors-only',
port: '3001',
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
}
config.module.rules.push(
{ test: /\.jsx?$/, exclude: /node_modules/, use: ['react-hot-loader', 'babel-loader'] },
{ test: /\.scss$/, use: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])}
)
module.exports = config
"start:dev": "webpack-dev-server --config webpack.dev.config.js",
Answer the question
In order to leave comments, you need to log in
dev server does not save files to disk, so this code did not work.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question