2
我正在使用webpack將.SASS生成一個.CSS文件,但它只在終端中輸入「webpack」時導出文件。當我運行「的WebPack-dev的服務器」,它看到的變化,但不生成/更改輸出.css文件:Webpack開發服務器 - 導出.CSS文件更改
var webpack = require('webpack');
var path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const autoprefixer = require('autoprefixer');
module.exports = {
devtool: 'inline-source-map',
entry: [
'webpack-dev-server/client?http://127.0.0.1:8080/',
'webpack/hot/only-dev-server',
'./src'
],
output: {
path: path.join(__dirname, 'public'),
filename: 'bundle.js', // this exports the final .js file
publicPath: '/public'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['react-hot', 'babel?presets[]=react,presets[]=es2015']
},
{
test: /\.scss$/, loader: ExtractTextPlugin.extract('css!sass') // this loads SASS
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin("./bundle.css") //this exports the CSS file
],
resolve: {
modulesDirectories: ['node_modules', 'src'],
extensions: ['', '.js', '.scss'],
root: [path.join(__dirname, './src')]
}
};
它的工作原理完全罰款只是「的WebPack」但我不知道如何使它使用服務器生成文件,以便每次更改樣式時都不必輸入終端。
'的WebPack-DEV-server'生成文件和內存供應,而不是從文件系統。 –
您需要將'style-loader'添加到ExtractTextPlugin:'ExtractTextPlugin.extract('style','css!sass')' –
嗯,它會呈現文件但不會將其放入目錄中。這裏是終端的屏幕截圖:http://i.imgur.com/OJGrpKY.png –