я делаю
npm install react-datepicker --save
https://reactdatepicker.com/
далее, я использую компонент в своем проекте
import DatePicker from 'react-datepicker';
import "react-datepicker/dist/react-datepicker.css";
в render
функция:
render(){
return(
<DatePicker />
);
}
проект скомпилирован - webpack:
webpack.config.js:
var path = require('path');
module.exports = {
entry: './index.js',
output: {
filename: 'order.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: ["react", "es2015", "stage-0"]
}
},
{
test: /\.css$/,
use: ['css-loader', 'style-loader']
},
{
test: /\\.(gif|ttf|eot|svg|woff2?)$/,
use: 'url-loader?name=[name].[ext]',
},
]
}
};
Я получаю следующую ошибку:
ERROR in ./node_modules/react-datepicker/dist/react-datepicker.css
Module build failed (from ./node_modules/css-loader/dist/cjs.js):
CssSyntaxError
(2:1) Unknown word
1 |
> 2 | var content = require("!!./react-datepicker.css");
| ^
3 |
4 | if(typeof content === 'string') content = [[module.id, content, '']];