如火热链接到css,用于在Webpack中启用热式样装入器以同步css的配置

如火热链接到css,用于在Webpack中启用热式样装入器以同步css的配置

我试图在Webpack中启用热样式装入器,但是我找不到正确的配置。这里是我的webpack.config.js:用于在Webpack中启用热式样装入器以同步css的配置

const webpack = require(‘webpack’);

const path = require(‘path’);

const buildPath = path.resolve(__dirname, ‘build’);

const nodeModulesPath = path.resolve(__dirname, ‘node_modules’);

const TransferWebpackPlugin = require(‘transfer-webpack-plugin’);

const config = {

entry: [

‘webpack/hot/dev-server’,

‘webpack/hot/only-dev-server’,

path.join(__dirname, ‘/src/app/app.js’),

],

resolve: {

extensions: [“”, “.js”],

},

devServer: {

contentBase: ‘src/www’,

devtool: ‘eval’,

hot: true,

inline: true,

port: 3232,

host: ‘0.0.0.0’,

},

devtool: ‘eval’,

output: {

path: buildPath,

filename: ‘app.js’,

},

plugins: [

new webpack.HotModuleReplacementPlugin(),

new TransferWebpackPlugin(

[{ from: ‘www’ }],

path.resolve(__dirname, “src”)

),

],

module: {

loaders: [

{

test: /\.js$/,

loaders: [‘react-hot’, ‘babel-loader’],

exclude: [nodeModulesPath],

},

{

test: /\.css$/,

loader: “style!css”,

},

],

},

eslint: {

configFile: ‘.eslintrc’,

},

};

module.exports = config;

而且我package.js文件:

{

“name”: “test-material-ui”,

“version”: “0.0.0-beta.1”,

“description”: “Sample project that uses material-ui”,

“scripts”: {

“start”: “webpack-dev-server –config webpack.config.js –progress –inline –colors”,

“build”: “webpack -p –define process.env.NODE_ENV=’\”production\”‘ –config webpack-production.config.js –progress –colors”,

“lint”: “eslint src && echo \”eslint: no lint errors\””

},

“private”: true,

“devDependencies”: {

“babel-core”: “^6.3.26”,

“babel-eslint”: “^6.0.0”,

“babel-loader”: “^6.2.4”,

“babel-preset-es2015”: “^6.3.13”,

“babel-preset-react”: “^6.3.13”,

“copy-webpack-plugin”: “^2.1.3”,

“css-loader”: “^0.23.1”,

“eslint”: “^2.5.1”,

“eslint-plugin-react”: “^4.0.0”,

“html-webpack-plugin”: “^2.7.2”,

“react-hot-loader”: “^1.3.0”,

“style-loader”: “^0.13.1”,

“transfer-webpack-plugin”: “^0.1.4”,

“webpack”: “^1.12.9”,

“webpack-dev-server”: “^1.14.0”

},

“dependencies”: {

“flexboxgrid”: “^6.3.0”,

“material-ui”: “^0.15.0-beta.1”,

“react”: “^15.0.1”,

“react-addons-css-transition-group”: “^15.0.1”,

“react-dom”: “^15.0.1”,

“react-redux”: “^4.4.5”,

“react-tap-event-plugin”: “^1.0.0”,

“redux”: “^3.4.0”

}

}

但无论我如何配置它,我不能让热同步工作(为的CSS,对于.js文件它工作得很好)!有人能告诉我正确的方法吗?

2016-05-06

Mehran

+1

只是为了排除这种可能性;你知道你必须要求JavaScript中的CSS? –

+0

@hansn你真棒,非常感谢你。 –

+0

如果您以帖子的形式发帖,我很乐意将其标记为答案。 –

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/111259.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号