Answer the question
In order to leave comments, you need to log in
Why doesn't w2ui work when building with Webpack?
W2ui does not work if you build with webpack. When connecting w2ui with a script on an html page, everything is fine.
The contents of the file with import libraries:
require('../libs/jquery/jquery-ui.css');
window.$ = window.jQuery = require('jquery');
require('jquery.browser');
require('jquery-ui');
require('w2ui/w2ui-1.4.2.min');
require('w2ui/w2ui-1.4.2.min.css');
require('../libs/gwtk.css');
require('../libs/gwtkse.js');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var precss = require('precss');
var autoprefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
entry: {
'app': './src/app.js'
},
output: {
path: './build',
filename: `[name].min.js`,
chunkFilename: '[name].min.js',
// publicPath: 'http://localhost:3000/'
},
devServer: {
outputPath: './dist',
port: 3000,
hot: true
},
resolve: {
extensions: ['', '.js']
},
// devtool: 'source-map',
module: {
loaders: [
{test: /\.js$/, loader: 'babel', exclude: /node_modules/},
{test: /\.css$/, loader: ExtractTextPlugin.extract("css?sourceMap!postcss")},
{test: /\.less$/, loader: ExtractTextPlugin.extract('css?sourceMap!postcss!less?sourceMap')},
{test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
{test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/font-woff"},
{test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=application/octet-stream"},
{test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, loader: "file"},
{test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, loader: "url?limit=10000&mimetype=image/svg+xml"},
{test: /\.(png|jpg)$/, loader: 'file?name=img/[name].[ext]'},
{test: /\.html$/, loader: 'raw'}
]
},
postcss: function () {
return [precss, autoprefixer];
},
plugins: [
new CleanWebpackPlugin('./build', {root: `${__dirname}/..`}),
new ExtractTextPlugin(`[name].min.css`, {allChunks: true}),
new HtmlWebpackPlugin({template: './index.html'})
]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question