react

2018-01-11  本文已影响0人  林ze宏
less-loader,需要增加包less-loader和less包
webpack.config.js 配置
{test: /\.less$/, loader: 'style-loader!css-loader!less-loader'}

根目录:webpack.config.js
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');

module.exports = {
  context: path.join(__dirname),
  devtool: debug ? "inline-sourcemap" : null,
  entry: "./src/js/index.js",
  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /(node_modules)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015']
        }
      }
    ]
  },
  output: {
    path: __dirname,
    filename: "./src/bundle.js"
  },
  plugins: debug ? [] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
  ],
};

最后运行:webpack

webpack-dev-server
webpack-dev-server --inline --hot(运行这个就可以了)
(webpack-dev-server --content-base build --inline --hot)

上一篇下一篇

猜你喜欢

热点阅读