can not set locale with webpack
Opened this issue · 1 comments
yaoyonstudio commented
Hi, guys, I really need some help.
I'm using angular 1.6, webpack and es6, I import moment and locale file , and did the configure as document said. but still can not set the locale lang.
Here's my code:
webpack.config.js:
process.env.NODE_ENV == 'production';
var debug = process.env.NODE_ENV !== 'production';
var webpack = require('webpack');
var path = require('path');
module.exports = {
context: path.join(__dirname, 'src'),
devtool: debug ? 'inline-sourcemap' : null,
//devtool: null,
entry: {
app: [ './js/app.js' ],
vendor: [ 'angular' ]
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
watch: true,
output: {
path: __dirname + '/src',
filename: 'main.js'
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
names: "vendor",
filename: "vendor.js",
minChunks: Infinity
})
]
};
index.html
<!DOCTYPE html>
<html ng-app="adwApp">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0">
<title>angular-datepicker-webpack</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<div date-picker class="orderDate" max-view="date" format="yyyy-MM-dd" min-view="date" view="date"></div>
<script src="vendor.js"></script>
<script src="main.js"></script>
</body>
</html>
app.js:
import angular from 'angular';
import moment from 'moment';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
require('imports?this=>window,exports=>false,define=>false!angular-datepicker');
angular.module('adwApp', ['datePicker'])
as you see, the locale setting not working
DanTalash commented
That's strange, as all locale related stuff is handled by moment. Try running moment.locale();
in your console after the page loads to verify that the locale is actually set to Chinese and didn't somehow get overridden.