我的Webpack版本没有将我的资源文件夹包含在dist版本中,这导致我的翻译文件永远不会被拾取,因此没有翻译...
文件结构:
dist
//I need my json files from src/resources here
src
app // holds all components
resources
locale-en-us.json
locale-fr-fr-json
locale-ru-ru.json
locale-zh-cn-json
webpack
webpack.common.js
webpack.server.js
weback.server.js:
const { root } = require('./helpers');
const { AotPlugin } = require('@ngtools/webpack');
module.exports = {
entry: root('./src/main.server.ts'),
output: {
filename: 'server.js'
},
target: 'node'
};
webpack.common.js
const { root } = require('./helpers');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
/**
* This is a common webpack config which is the base for all builds
*/
module.exports = {
devtool: 'cheap-module-source-map',
resolve: {
extensions: ['.ts', '.js']
},
output: {
path: root('dist')
},
module: {
rules: [
{ test: /\.ts$/, loader: '@ngtools/webpack' },
{ test: /\.html$/, loader: 'raw-loader' },
{ test: /\.less$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?sourceMap!less-loader?sourceMap' }) },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?sourceMap!sass-loader?sourceMap' }) },
{ test: /\.css$/, loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader?sourceMap' }) },
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=8192&minetype=application/font-woff&name=fonts/[name].[hash].[ext]' },
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file-loader?name=fonts/[name].[hash].[ext]' },
{ test: /\.(jpg|jpeg|png|gif)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url-loader?limit=4096&name=images/[name].[hash].[ext]' }
]
},
plugins: [
new ExtractTextPlugin('[name].css')
]
};
我正在使用Webpack v2.5.1。谁知道我在这里失踪了什么?根据我的理解,我不应该在Webpack版本2.0 +
中包含任何json加载器我是否需要从某个资源文件夹导入我的文件?
答案 0 :(得分:2)
Webpack仅考虑代码明确导入/要求的文件。
如果您只想将某些文件移动到构建目录中,请查看this answer如何设置copy-webpack-plugin。