मैं एक ही भंडार में अपने सर्वर & ग्राहक कोड रखने के लिए, हालांकि मैं Webpack केवल ग्राहक बनाने के लिए उपयोग: अगर मैं src/सर्वर फ़ोल्डर हटानावेबपैक निर्दिष्ट फ़ोल्डर को छोड़कर क्यों नहीं है?
मेरे परियोजना ठीक बनाता है।
/// <reference path="../../../../typings/main.d.ts" />
कैसे:
[1m[31mERROR in /home/rje/projects/ekaya/typings/main/ambient/react-dom/index.d.ts
(70,5): error TS2300: Duplicate identifier 'export='.
जो Webpack के कारण होता है अपने सर्वर फ़ोल्डर में फ़ाइलें स्थापित करता है, में से एक बनाने की कोशिश: लेकिन जब यह नहीं है मैं की तरह इन सभी 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 config है अगर यह मदद करता है:
//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
नहीं, मुझे लगता है कि मुझे सबकुछ अलग फ़ोल्डर में ले जाना पड़ा - यानी वेबपैक कॉन्फ़िगरेशन को क्लाइंट फ़ोल्डर – Richard
धन्यवाद में डालें। एक बिल्ड इशारा को दूर करने की कोशिश करते समय, मैंने देखा कि किसी भी तरह से शामिल/बहिष्कृत पूर्ण पथ स्ट्रिंग की तुलना में regex द्वारा अधिक प्रभावित प्रतीत होता है। ऐसा कुछ हो सकता है जो मैं गलत कर रहा था, लेकिन यह कोशिश करने लायक हो सकता है कि अगले अवसर पर – superjos