You may need an appropriate loader to handle this file type babel and webpack -
so file structure pretty straight forward.
~
/dist /node_modules /src .babelrc index.js package.json webpack.config.js
what trying accomplish trying run command "webpack" have build dist folder compiled code. module.exporting out use it.
however, keep running error says may need appropriate loader file type. feel if have of dev devependies need compile.
here following webpack.config.js package.json
{ "name": "test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"error: no test specified\" && exit 1", "webpack": "webpack" }, "keywords": [], "author": "", "license": "isc", "dependencies": { "babel-preset-stage-1": "^6.24.1", "lodash": "^4.17.4", "react": "^15.6.1", "react-dom": "^15.6.1" }, "devdependencies": { "babel-core": "^6.26.0", "babel-loader": "^7.1.2", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "jsx-loader": "^0.13.2", "webpack": "^3.5.6", "webpack-dev-server": "^2.8.1" } } module.exports = { entry: [ './src/components/select.jsx' ], output: { path: __dirname + /dist/, publicpath: '/', filename: 'form-field.js' }, module: { loaders: [{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['react', 'es2015', 'stage-1'] } }] }, resolve: { extensions: ['.js', '.jsx'] }, devserver: { historyapifallback: true, contentbase: './' } };
you don't allow file types in loader. add test
key.
loaders: [{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel', query: { presets: ['react', 'es2015', 'stage-1'] } }]
Comments
Post a Comment