私は唯一のクライアントを構築するためのWebPACKを使用しても、私は、同じリポジトリに私のサーバー&クライアントコードを保つ:私はSRC /サーバーのフォルダを削除する場合指定したフォルダを除外するWebpackがないのはなぜですか?
私のプロジェクトはうまくビルドします。含まれている私のサーバーのフォルダ内のファイルの1を構築しようとしているのWebPACKによって引き起こされる
[1m[31mERROR in /home/rje/projects/ekaya/typings/main/ambient/react-dom/index.d.ts
(70,5): error TS2300: Duplicate identifier 'export='.
:それがあるとき、私はのようにすべてのこれらのWebPACK活字体の重複定義エラーが発生します
方法/// <reference path="../../../../typings/main.d.ts" />
Webpackにサーバーフォルダを完全に無視させることはできますか?
私は私のwebpack.config.jsで試してみた:それは場合に役立ちます
var rootPath = __dirname;
var srcPath = path.join(rootPath, 'src/client');
var distPath = path.join(rootPath, 'dist/client');
var serverPath = path.join(rootPath, 'src/serve
...
loaders:
[
{test: /\.js$/, loader: 'babel-loader?cacheDirectory', include: [srcPath], exclude: [serverPath]},
{test: /\.jsx$/, loader: 'babel-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
{test: /\.ts$/, loader: 'ts-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
{test: /\.tsx$/, loader: 'ts-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
はここでいっぱいのWebPACKの設定です:
//https://webpack.github.io/docs/configuration.html
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var path = require('path');
var rootPath = __dirname; // e.g. ~/projects/ekaya
var srcPath = path.join(rootPath, 'src/client');
var distPath = path.join(rootPath, 'dist/client');
var serverPath = path.join(rootPath, 'src/server');
module.exports =
{
bail: true,
cache: false,
context: rootPath,
debug: true,
devtool: 'source-map', //inline-source-map, https://webpack.github.io/docs/configuration.html#devtool
target: 'web', //node, web
devServer:
{
contentBase: distPath,
historyApiFallback: true,
outputPath: path.join(distPath, 'devServer')
},
entry:
{
app: path.join(srcPath, 'app/home.jsx'),
lib: ['react', 'react-router', 'react-dom', 'jquery', 'lodash', 'history']
},
output:
{
path: distPath,
publicPath: '',
filename: '[name].js',
pathInfo: true
},
resolve:
{
root: srcPath,
extensions: ['', '.js', '.jsx', '.ts', '.tsx'],
modulesDirectories: ['node_modules', srcPath, 'typings']
},
module:
{
loaders:
[
{test: /\.js$/, loader: 'babel-loader?cacheDirectory', include: [srcPath], exclude: [serverPath]},
{test: /\.jsx$/, loader: 'babel-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
{test: /\.ts$/, loader: 'ts-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
{test: /\.tsx$/, loader: 'ts-loader?cacheDirectory', include: [srcPath], exclude: [serverPath] },
{test: /\.scss$/, loaders: ['style', 'css', 'sass']},
{test: /\.png$/, loader: 'file-loader'},
{test: /\.jpg$/, loader: 'file-loader'},
{test: /\.jpeg$/, loader: 'file-loader'},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: 'file-loader?mimetype=image/svg+xml'},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/font-woff"},
{test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/font-woff"},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader?mimetype=application/octet-stream"},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file-loader"}
]
},
plugins:
[
new CopyWebpackPlugin
([
{ from: path.join(srcPath, 'images'), to: 'images' }
]),
new webpack.optimize.CommonsChunkPlugin('lib', 'lib.js'),
new HtmlWebpackPlugin
({
inject: true,
template: path.join(srcPath, 'index.html')
}),
new webpack.NoErrorsPlugin()
]
};
あなたはこれまでこれを解決しましたか? – superjos
いいえ、最終的にすべてを個別のフォルダに移動する必要があると思います。つまり、Webpbackの設定をクライアントフォルダに入れてください。 – Richard
ありがとうございます。ビルドの問題を克服しようとしているうちに、include/excludeが絶対パス文字列よりも正規表現の影響を受けているように見えました。それは私が間違っていたものかもしれませんが、次の機会にそれを試みる価値があるかもしれません – superjos