oyslin / replace-in-file-webpack-plugin

A webpack plugin to quickly replace text in one or more files.
MIT License
34 stars 14 forks source link

Replacements not working #7

Open manchuwook opened 6 years ago

manchuwook commented 6 years ago

This doesn't seem to work

// webpack.config.js
var webpack = require('webpack');
const path = require('path');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');

"use strict";

module.exports = {
    entry: {
        main: '/'
    },
    output: {
        publicPath: '/',
        path: path.resolve(__dirname, 'wwwroot'),
        filename: "./dist/[name].bundle.js"
    },
    devServer: {
        contentBase: ".",
        host: "localhost",
        port: 9000
    },
    mode: "development",
    plugins: [
        new ReplaceInFileWebpackPlugin([{
            dir: path.resolve(__dirname, 'Areas/Characters/Scripts/character-designer/build/default/'),
            test: /\.html$/,
            rules: [{
                search: '@webcomponents',
                replace: '@{\'@webcomponents\'}'
            }]
        }])
    ]
};

I'm just trying to take a polymer-generated html file and replace the script bit so I can use it as a cshtml file - Razor treats it like a helper.

ZardoZAntony commented 4 years ago

This plugin work good only with regExp