如何忽略webpack,babel和webpack-dev-server中的目录?

时间:2017-06-15 08:29:16

标签: javascript webpack webpack-dev-server

我有预制项目,它运行正常,但是当我编辑文件api / index.php时webpack正在重建项目,而当我没有因为。#index.php文件而没有将文件保存在emacs中时失败。

如何忽略api目录或仅忽略app目录中的文件?我需要从根目录复制文件,因此我无法使用context,因为webpack不会在根目录中看到index.html或.htaccess等文件。

这是我的webpack配置文件:

module.exports = {
    entry:  {
        app: path.resolve('./app') + '/app.jsx'
    },
    output: {
        path: path.resolve('./dist'),
        filename: "[name].js"
    },
    plugins: ([
        new webpack.optimize.CommonsChunkPlugin({
            name: "vendor",
            minChunks: isNodeModule
        }),
        new webpack.DefinePlugin({
            PRODUCTION: ENV === 'production'
        }),
        new CopyWebpackPlugin([
            {from: 'index.html'},
            {from: '.htaccess'},
            {from: 'config.json'},
            {from: 'api', to: 'api'}
        ])
    ]).concat(ENV==='production' ? [
        new webpack.optimize.UglifyJsPlugin({
            output: {
                comments: false
            },
            compress: {
                unsafe_comps: true,
                properties: true,
                keep_fargs: false,
                pure_getters: true,
                collapse_vars: true,
                unsafe: true,
                warnings: false,
                screw_ie8: true,
                sequences: true,
                dead_code: true,
                drop_debugger: true,
                comparisons: true,
                conditionals: true,
                evaluate: true,
                booleans: true,
                loops: true,
                unused: true,
                hoist_funs: true,
                if_return: true,
                join_vars: true,
                cascade: true,
                drop_console: true
            }
        })
    ] : []),
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
                query: {
                    presets: ['es2015']
                }
            },
            {
                test: /\.css$/,
                loaders: ['style-loader', 'css-loader']
            }
        ]
    },
    resolve: {
        extensions: ['.jsx', '.js', '.json']
    },
    devServer: {
        historyApiFallback: true,
        open: true
    }
};

编辑:看起来这与dev-server无关,因为当我在Emacs中有未保存的文件时,我也无法运行webpack。

0 个答案:

没有答案