Webpack强制通过CLI webpack工具重新渲染(重新构建,重新编译)

时间:2016-07-01 11:57:29

标签: javascript node.js sass webpack frontend

Somethimes webpack没有接受我对jsx和scss文件的更改,因此它没有编译更新的 main.scss main.js (有时)。

webpack运行在安装在alpine linux轻量级环境中的docker容器中。

我想ssh到docker容器中并直接通过webpack命令行工具强制重新编译更改。

可能有一些手动方式 $ webpack --force-complie或--force-watch 或类似的东西,以手动运行main.scss和main.js的重建过程

有没有办法这样做?

这是我的 webpack.config.js 文件:

    const ExtractTextPlugin = require("extract-text-webpack-plugin");
const webpack = require("webpack");
const autoprefixer = require("autoprefixer");


if (process.env.NODE_ENV === "development") {
    require("dotenv").config();
}

module.exports = {
    entry: "./assets/shared/main.jsx",
    output: {
        path: "public",
        publicPath: "/",
        filename: "main.js"
    },
    module: {
        preLoaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules)/,
                loader: "eslint-loader"
            }
        ],
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules)/,
                loader: "babel-loader",
                query: {
                    presets: ["react", "es2015", "stage-0"]
                }
            },
            {
                test: /\.scss$/,
                exclude: /(node_modules)/,
                loader: ExtractTextPlugin.extract(
                    "style-loader",
                    "css-loader?sourceMap!postcss-loader!sass-loader"
                )
            },
            {
                test: /\.(png|jpg)$/,
                // inline base64 URLs for <=4k images, direct URLs for the rest
                loader: "url-loader?limit=4096"
            }
        ]
    },
    devtool: "source-map",
    stats: { children: false },
    postcss: function () {
        return [autoprefixer];
    },
    eslint: {
        quiet: true
    },
    plugins: [
        new ExtractTextPlugin("styles.css"),
        new webpack.EnvironmentPlugin([
            "NODE_ENV", // This is used to run React in "production" mode
            "API_URL"
        ])
    ]
};

0 个答案:

没有答案