2016-10-26 7 views
0

on a functionに基づいて置き換えられる文字列置換プラグインを使用してwebpack devサーバーで実行しています。私は交換の価値が私のソースファイルを上書きしていることを知っています。Webpack + eslintはlintingのソース変更を置き換えます

マイDevのサーバー構成はこれです:文字列置換プラグインの設定

const devServer = (options) => { 
    return { 
    devServer: { 
     hot: true, 
     inline: true, 
     stats: 'errors-only', 
     host: options.host, 
     port: options.port, 
     historyApiFallback: true 
    }, 
    plugins: [ 
     new webpack.HotModuleReplacementPlugin({ 
     multiStep: true 
     }) 
    ] 
    } 
} 

です:

const constants = (data) => { 
    return { 
     module: { 
     loaders: [ 
      { 
      test: /\.jsx?$/, 
      loader: StringReplacePlugin.replace({ 
       replacements:[ 
       { 
        pattern:/\`CONSTANT_(.*)\`/g, 
        replacement:(match,p1,offset,string)=>{ 
        console.log('MATCH '+p1) 
        const keys = p1.split('.') 
        let current = data 
        keys.forEach((key)=>{ 
         current = current[key] 
        }) 
        console.log('Replacing '+p1+' with '+current) 
        return `'${current}'` 
        } 
       } 
       ] 
      }) 
      } 
     ] 
     }, 
     plugins: [ 
     new StringReplacePlugin() 
     ] 
    } 
    } 

エントリー/ ouptut値は以下のとおりです。

const base = { 
    entry: { 
    app: path.resolve(PATHS.app, './index.jsx') 
    }, 
    output: { 
    path: PATHS.build, 
    filename: 'app.js', 
    publicPath: '/' 
    }, 
    resolve: { 
    extensions: ['', '.js', '.jsx', '.json'] 
    } 
} 

何らかの理由がありますwebpack dev serverがソース上のファイルを変更する理由

EDIT:1つの追加JSの一部:?

const js = (paths) => { 
    const cacheDir = (process.env.CACHE_DIRECTORY ? process.env.CACHE_DIRECTORY : 'true') 
    return { 

    module: { 
     loaders: [ 
     { 
      test: /\.jsx?$/, 
      exclude: /(node_modules|bower_components)/, 
      loaders: [ 
      `babel?cacheDirectory=${cacheDir}`, // presets on .babelrc 
      'eslint-loader?fix' 
      ], 
      include: paths 
     } 
     ] 
    } 
    } 
} 

編集2原因seesm eslint-ローダーすべき適切な行動が達成される取り外したときに、固定してください。今私はそれを防ぐ方法を模索しています

答えて

0

すべての変更の前にeslint-loader?

関連する問題